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.

collection.js 785B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 'use strict';
  2. /**
  3. * methods a collection must implement
  4. */
  5. var methods = [
  6. 'find',
  7. 'findOne',
  8. 'update',
  9. 'updateMany',
  10. 'updateOne',
  11. 'replaceOne',
  12. 'remove',
  13. 'count',
  14. 'distinct',
  15. 'findAndModify',
  16. 'aggregate',
  17. 'findStream',
  18. 'deleteOne',
  19. 'deleteMany'
  20. ];
  21. /**
  22. * Collection base class from which implementations inherit
  23. */
  24. function Collection() {}
  25. for (var i = 0, len = methods.length; i < len; ++i) {
  26. var method = methods[i];
  27. Collection.prototype[method] = notImplemented(method);
  28. }
  29. module.exports = exports = Collection;
  30. Collection.methods = methods;
  31. /**
  32. * creates a function which throws an implementation error
  33. */
  34. function notImplemented(method) {
  35. return function() {
  36. throw new Error('collection.' + method + ' not implemented');
  37. };
  38. }