permissions.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 'use strict';
  2. const denied = exports;
  3. denied.distinct = function(self) {
  4. if (self._fields && Object.keys(self._fields).length > 0) {
  5. return 'field selection and slice';
  6. }
  7. const keys = Object.keys(denied.distinct);
  8. let err;
  9. keys.every(function(option) {
  10. if (self.options[option]) {
  11. err = option;
  12. return false;
  13. }
  14. return true;
  15. });
  16. return err;
  17. };
  18. denied.distinct.select =
  19. denied.distinct.slice =
  20. denied.distinct.sort =
  21. denied.distinct.limit =
  22. denied.distinct.skip =
  23. denied.distinct.batchSize =
  24. denied.distinct.maxScan =
  25. denied.distinct.snapshot =
  26. denied.distinct.hint =
  27. denied.distinct.tailable = true;
  28. // aggregation integration
  29. denied.findOneAndUpdate =
  30. denied.findOneAndRemove = function(self) {
  31. const keys = Object.keys(denied.findOneAndUpdate);
  32. let err;
  33. keys.every(function(option) {
  34. if (self.options[option]) {
  35. err = option;
  36. return false;
  37. }
  38. return true;
  39. });
  40. return err;
  41. };
  42. denied.findOneAndUpdate.limit =
  43. denied.findOneAndUpdate.skip =
  44. denied.findOneAndUpdate.batchSize =
  45. denied.findOneAndUpdate.maxScan =
  46. denied.findOneAndUpdate.snapshot =
  47. denied.findOneAndUpdate.tailable = true;
  48. denied.count = function(self) {
  49. if (self._fields && Object.keys(self._fields).length > 0) {
  50. return 'field selection and slice';
  51. }
  52. const keys = Object.keys(denied.count);
  53. let err;
  54. keys.every(function(option) {
  55. if (self.options[option]) {
  56. err = option;
  57. return false;
  58. }
  59. return true;
  60. });
  61. return err;
  62. };
  63. denied.count.slice =
  64. denied.count.batchSize =
  65. denied.count.maxScan =
  66. denied.count.snapshot =
  67. denied.count.tailable = true;