Skip to content

Commit

Permalink
refactor: add isDefiningProjection helper re: #5881
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 8, 2017
1 parent 83d9a98 commit cc84026
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/services/projection/isDefiningProjection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

/*!
* ignore
*/

module.exports = function isDefiningProjection(val) {
if (val == null) {
// `undefined` or `null` become exclusive projections
return true;
}
if (typeof val === 'object') {
// Only cases where a value does **not** define whether the whole projection
// is inclusive or exclusive are `$meta` and `$slice`.
return !('$meta' in val) && !('$slice' in val);
}
return true;
}

0 comments on commit cc84026

Please sign in to comment.