Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isExclusive.js 635B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const isDefiningProjection = require('./isDefiningProjection');
  3. /*!
  4. * ignore
  5. */
  6. module.exports = function isExclusive(projection) {
  7. const keys = Object.keys(projection);
  8. let ki = keys.length;
  9. let exclude = null;
  10. if (ki === 1 && keys[0] === '_id') {
  11. exclude = !!projection[keys[ki]];
  12. } else {
  13. while (ki--) {
  14. // Does this projection explicitly define inclusion/exclusion?
  15. // Explicitly avoid `$meta` and `$slice`
  16. if (keys[ki] !== '_id' && isDefiningProjection(projection[keys[ki]])) {
  17. exclude = !projection[keys[ki]];
  18. break;
  19. }
  20. }
  21. }
  22. return exclude;
  23. };