Skip to content

Commit

Permalink
Got rid of double projection set.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgolemme committed Jun 20, 2024
1 parent 7d9809c commit 957a8ab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/util/mongo.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ const findOneResourceWithQuery = async (query, resourceType) => {
return collection.findOne(query, { projection: { _id: 0 } });
};

/**
* Searches the database for the one or more resources based on a mongo query and returns the data.
* @param {Object} query the mongo query to use
* @param {string} resourceType type of desired resource, signifies collection resource is stored in
* @return {Array} the data of the found documents
*/
const findResourcesWithQuery = async (query, resourceType, options = { projection: { _id: 0 } }) => {
options.projection['_id'] = 0;
const collection = db.collection(resourceType);
const results = collection.find(query, options);
return results.toArray();
Expand Down

0 comments on commit 957a8ab

Please sign in to comment.