Linting
This commit is contained in:
@@ -63,7 +63,10 @@ export const getDocumentByField = async (collectionName, field, value) => {
|
||||
};
|
||||
|
||||
// Function to retrieve a document by multiple fields
|
||||
export const getDocumentByFields = async (collectionName, ...fieldValuePairs) => {
|
||||
export const getDocumentByFields = async (
|
||||
collectionName,
|
||||
...fieldValuePairs
|
||||
) => {
|
||||
log.DEBUG("Getting document by fields:", collectionName, fieldValuePairs);
|
||||
const db = await connectToDatabase();
|
||||
try {
|
||||
@@ -99,7 +102,12 @@ export const upsertDocumentByField = async (
|
||||
value,
|
||||
updatedFields,
|
||||
);
|
||||
return await updateDocumentByFields(collectionName, updatedFields, { upsert: true }, [field, value]);
|
||||
return await updateDocumentByFields(
|
||||
collectionName,
|
||||
updatedFields,
|
||||
{ upsert: true },
|
||||
[field, value],
|
||||
);
|
||||
};
|
||||
|
||||
// Function to update a document by a specific field
|
||||
@@ -112,9 +120,14 @@ export const upsertDocumentByFields = async (
|
||||
"Upsert document by fields:",
|
||||
collectionName,
|
||||
updatedFields,
|
||||
fieldValuePairs
|
||||
fieldValuePairs,
|
||||
);
|
||||
return await updateDocumentByFields(
|
||||
collectionName,
|
||||
updatedFields,
|
||||
{ upsert: true },
|
||||
fieldValuePairs,
|
||||
);
|
||||
return await updateDocumentByFields(collectionName, updatedFields, { upsert: true }, fieldValuePairs);
|
||||
};
|
||||
|
||||
// Function to update a document by a specific field
|
||||
@@ -133,7 +146,10 @@ export const updateDocumentByField = async (
|
||||
updatedFields,
|
||||
options,
|
||||
);
|
||||
return await updateDocumentByFields(collectionName, updatedFields, options, [field, value])
|
||||
return await updateDocumentByFields(collectionName, updatedFields, options, [
|
||||
field,
|
||||
value,
|
||||
]);
|
||||
};
|
||||
|
||||
// Function to update a document by multiple fields
|
||||
@@ -163,7 +179,7 @@ export const updateDocumentByFields = async (
|
||||
const result = await collection.updateOne(
|
||||
query,
|
||||
{ $set: updatedFields },
|
||||
options
|
||||
options,
|
||||
);
|
||||
log.DEBUG("Document updated:", result.modifiedCount);
|
||||
return result.modifiedCount;
|
||||
@@ -182,7 +198,10 @@ export const deleteDocumentByField = async (collectionName, field, value) => {
|
||||
};
|
||||
|
||||
// Function to delete a document by multiple fields
|
||||
export const deleteDocumentByFields = async (collectionName, ...fieldValuePairs) => {
|
||||
export const deleteDocumentByFields = async (
|
||||
collectionName,
|
||||
...fieldValuePairs
|
||||
) => {
|
||||
log.DEBUG("Delete document by fields:", collectionName, fieldValuePairs);
|
||||
const db = await connectToDatabase();
|
||||
try {
|
||||
@@ -203,4 +222,4 @@ export const deleteDocumentByFields = async (collectionName, ...fieldValuePairs)
|
||||
} finally {
|
||||
await db.close();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user