thoughts/node_modules/mongoose/node_modules/mquery/lib/collection/collection.js
node_modules/mongoose/node_modules/mquery/lib/collection/collection.jsRaw
1'use strict';
2
3/**
4 * methods a collection must implement
5 */
6
7var 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
23function Collection () {}
24
25for (var i = 0, len = methods.length; i < len; ++i) {
26 var method = methods[i];
27 Collection.prototype[method] = notImplemented(method);
28}
29
30module.exports = exports = Collection;
31Collection.methods = methods;
32
33/**
34 * creates a function which throws an implementation error
35 */
36
37function notImplemented (method) {
38 return function () {
39 throw new Error('collection.' + method + ' not implemented');
40 }
41}
42