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