Skip to content

Commit

Permalink
Merge pull request #234 from flyvictor/PO-3204-mongo-upgrade-is-coming
Browse files Browse the repository at this point in the history
fox(PO-2304): small fix
  • Loading branch information
alexgolafv authored Apr 11, 2022
2 parents 05ccd3f + 064c89b commit c1903e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/adapters/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ adapter.find = function(model, query, projection){
if (!_.isObject(query)) query = {id: query};

projection = projection || {};
projection.select = removeUselessProjectionSelect(projection.select);
projection.select = removeUselessProjectionSelect(projection.select, model);
projection.limit = 1;
return new Promise(function(resolve, reject){
return adapter.findMany(model, query, projection).then(function(resources){
Expand Down Expand Up @@ -508,7 +508,7 @@ adapter._findMany = function(model, query, projection, count) {
}

projection = projection || {};
projection.select = removeUselessProjectionSelect(projection.select);
projection.select = removeUselessProjectionSelect(projection.select, model);
projection.skip = 0;

if (projection.page && projection.page > 0) {
Expand Down Expand Up @@ -1170,7 +1170,7 @@ function removeUselessProjectionSelect (select, model) {
return acc;
}, []);

const collectionName = model.collection.collectionName;
const collectionName = model.collection && model.collection.collectionName;
keysToDelete.forEach((key) => {
console.warn(`[fortune::mongodb-adapter] Useless "${key}" select key required for model ${collectionName}.`);

Expand Down

0 comments on commit c1903e0

Please sign in to comment.