node.js
2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
'use strict';
/**
* Module dependencies
*/
const Collection = require('./collection');
class NodeCollection extends Collection {
constructor(col) {
super();
this.collection = col;
this.collectionName = col.collectionName;
}
/**
* find(match, options, function(err, docs))
*/
find(match, options, cb) {
const cursor = this.collection.find(match, options);
try {
cursor.toArray(cb);
} catch (error) {
cb(error);
}
}
/**
* findOne(match, options, function(err, doc))
*/
findOne(match, options, cb) {
this.collection.findOne(match, options, cb);
}
/**
* count(match, options, function(err, count))
*/
count(match, options, cb) {
this.collection.count(match, options, cb);
}
/**
* distinct(prop, match, options, function(err, count))
*/
distinct(prop, match, options, cb) {
this.collection.distinct(prop, match, options, cb);
}
/**
* update(match, update, options, function(err[, result]))
*/
update(match, update, options, cb) {
this.collection.update(match, update, options, cb);
}
/**
* update(match, update, options, function(err[, result]))
*/
updateMany(match, update, options, cb) {
this.collection.updateMany(match, update, options, cb);
}
/**
* update(match, update, options, function(err[, result]))
*/
updateOne(match, update, options, cb) {
this.collection.updateOne(match, update, options, cb);
}
/**
* replaceOne(match, update, options, function(err[, result]))
*/
replaceOne(match, update, options, cb) {
this.collection.replaceOne(match, update, options, cb);
}
/**
* deleteOne(match, options, function(err[, result])
*/
deleteOne(match, options, cb) {
this.collection.deleteOne(match, options, cb);
}
/**
* deleteMany(match, options, function(err[, result])
*/
deleteMany(match, options, cb) {
this.collection.deleteMany(match, options, cb);
}
/**
* remove(match, options, function(err[, result])
*/
remove(match, options, cb) {
this.collection.remove(match, options, cb);
}
/**
* findOneAndDelete(match, options, function(err[, result])
*/
findOneAndDelete(match, options, cb) {
this.collection.findOneAndDelete(match, options, cb);
}
/**
* findOneAndUpdate(match, update, options, function(err[, result])
*/
findOneAndUpdate(match, update, options, cb) {
this.collection.findOneAndUpdate(match, update, options, cb);
}
/**
* var cursor = findCursor(match, options)
*/
findCursor(match, options) {
return this.collection.find(match, options);
}
/**
* aggregation(operators..., function(err, doc))
* TODO
*/
}
/**
* Expose
*/
module.exports = exports = NodeCollection;