mongodb 2.1.1 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +7 -0
- package/lib/cursor.js +11 -1
- package/lib/db.js +1 -0
- package/lib/gridfs/grid_store.js +8 -12
- package/lib/mongo_client.js +3 -2
- package/mongolabs.js +427 -0
- package/package.json +2 -2
- package/test.js +12 -0
package/HISTORY.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
2.1.2 12-23-2015
|
|
2
|
+
----------------
|
|
3
|
+
* Updated mongodb-core to 1.2.30.
|
|
4
|
+
* Pool allocates size + 1 connections when using replicasets, reserving additional pool connection for monitoring exclusively.
|
|
5
|
+
* Fixes bug when all replicaset members are down, that would cause it to fail to reconnect using the originally provided seedlist.
|
|
6
|
+
|
|
7
|
+
|
|
1
8
|
2.1.1 12-13-2015
|
|
2
9
|
----------------
|
|
3
10
|
* Surfaced checkServerIdentity options for MongoClient, Server, ReplSet and Mongos to allow for control of the checkServerIdentity method available in Node.s 0.12.x or higher.
|
package/lib/cursor.js
CHANGED
|
@@ -156,7 +156,6 @@ var Cursor = function(bson, ns, cmd, options, topology, topologyOptions) {
|
|
|
156
156
|
// Legacy fields
|
|
157
157
|
this.timeout = self.s.options.noCursorTimeout == true;
|
|
158
158
|
this.sortValue = self.s.cmd.sort;
|
|
159
|
-
this.readPreference = self.s.options.readPreference;
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
/**
|
|
@@ -1104,6 +1103,17 @@ Cursor.prototype._read = function(n) {
|
|
|
1104
1103
|
});
|
|
1105
1104
|
}
|
|
1106
1105
|
|
|
1106
|
+
Object.defineProperty(Cursor.prototype, 'readPreference', {
|
|
1107
|
+
enumerable:true,
|
|
1108
|
+
get: function() {
|
|
1109
|
+
if (!this || !this.s) {
|
|
1110
|
+
return null;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
return this.s.options.readPreference;
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1107
1117
|
Object.defineProperty(Cursor.prototype, 'namespace', {
|
|
1108
1118
|
enumerable: true,
|
|
1109
1119
|
get: function() {
|
package/lib/db.js
CHANGED
|
@@ -281,6 +281,7 @@ var executeCommand = function(self, command, options, callback) {
|
|
|
281
281
|
// Execute command
|
|
282
282
|
self.s.topology.command(f('%s.$cmd', dbName), command, options, function(err, result) {
|
|
283
283
|
if(err) return handleCallback(callback, err);
|
|
284
|
+
if(options.full) return handleCallback(callback, null, result);
|
|
284
285
|
handleCallback(callback, null, result.result);
|
|
285
286
|
});
|
|
286
287
|
}
|
package/lib/gridfs/grid_store.js
CHANGED
|
@@ -507,18 +507,14 @@ var close = function(self, callback) {
|
|
|
507
507
|
|
|
508
508
|
// Build the mongo object
|
|
509
509
|
if(self.uploadDate != null) {
|
|
510
|
-
|
|
511
|
-
if(err
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if(err) {
|
|
515
|
-
if(typeof callback == 'function') return callback(err); else throw err;
|
|
516
|
-
}
|
|
510
|
+
buildMongoObject(self, function(err, mongoObject) {
|
|
511
|
+
if(err) {
|
|
512
|
+
if(typeof callback == 'function') return callback(err); else throw err;
|
|
513
|
+
}
|
|
517
514
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
});
|
|
515
|
+
files.save(mongoObject, options, function(err) {
|
|
516
|
+
if(typeof callback == 'function')
|
|
517
|
+
callback(err, mongoObject);
|
|
522
518
|
});
|
|
523
519
|
});
|
|
524
520
|
} else {
|
|
@@ -931,7 +927,7 @@ var seek = function(self, position, seekLocation, callback) {
|
|
|
931
927
|
nthChunk(self, newChunkNumber, function(err, chunk) {
|
|
932
928
|
if(err) return callback(err, null);
|
|
933
929
|
if(chunk == null) return callback(new Error('no chunk found'));
|
|
934
|
-
|
|
930
|
+
|
|
935
931
|
// Set the current chunk
|
|
936
932
|
self.currentChunk = chunk;
|
|
937
933
|
self.position = targetPosition;
|
package/lib/mongo_client.js
CHANGED
|
@@ -215,8 +215,8 @@ var connect = function(url, options, callback) {
|
|
|
215
215
|
var _server_options = {
|
|
216
216
|
poolSize:1
|
|
217
217
|
, socketOptions: {
|
|
218
|
-
connectTimeoutMS: providedSocketOptions.connectTimeoutMS ||
|
|
219
|
-
, socketTimeoutMS: providedSocketOptions.socketTimeoutMS ||
|
|
218
|
+
connectTimeoutMS: providedSocketOptions.connectTimeoutMS || (1000 * 120)
|
|
219
|
+
, socketTimeoutMS: providedSocketOptions.socketTimeoutMS || (1000 * 120)
|
|
220
220
|
}
|
|
221
221
|
, auto_reconnect:false};
|
|
222
222
|
|
|
@@ -256,6 +256,7 @@ var connect = function(url, options, callback) {
|
|
|
256
256
|
if(!err) {
|
|
257
257
|
// Close the connection
|
|
258
258
|
db.close();
|
|
259
|
+
// Get the last ismaster document
|
|
259
260
|
var isMasterDoc = db.serverConfig.isMasterDoc;
|
|
260
261
|
|
|
261
262
|
// Check what type of server we have
|
package/mongolabs.js
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PROPRIETARY AND CONFIDENTIAL
|
|
3
|
+
*
|
|
4
|
+
* The contents of this example are proprietary and confidential, and may not be used or distributed without express
|
|
5
|
+
* written permission from MongoLab.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
var mongodb = require("mongodb");
|
|
10
|
+
var async = require("async");
|
|
11
|
+
|
|
12
|
+
var ObjectId = mongodb.ObjectID;
|
|
13
|
+
|
|
14
|
+
//mongodb.Logger.setLevel("debug");
|
|
15
|
+
var uri = process.env.MONGODB_URI;
|
|
16
|
+
|
|
17
|
+
function log(s) {
|
|
18
|
+
console.log(new Date().toISOString() + " " + s);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
log("Connecting...");
|
|
22
|
+
mongodb.MongoClient.connect(
|
|
23
|
+
uri,
|
|
24
|
+
{
|
|
25
|
+
replSet: {
|
|
26
|
+
//poolSize: 10
|
|
27
|
+
socketOptions: {
|
|
28
|
+
connectTimeoutMS: 60 * 1000
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
function (err, db) {
|
|
33
|
+
if (err) {
|
|
34
|
+
log("Error trying to connect.");
|
|
35
|
+
log(err.stack);
|
|
36
|
+
} else {
|
|
37
|
+
log("Connected.");
|
|
38
|
+
db.serverConfig.on('joined', function(t, s) {
|
|
39
|
+
log("joined :: " + t + " :: " + s.name);
|
|
40
|
+
});
|
|
41
|
+
db.serverConfig.on('left', function(t, s) {
|
|
42
|
+
log("joined :: " + t + " :: " + s.name);
|
|
43
|
+
});
|
|
44
|
+
db.serverConfig.on('timeout', function(err) {
|
|
45
|
+
log("timeout :: ");
|
|
46
|
+
log(err.stack);
|
|
47
|
+
});
|
|
48
|
+
log("Running aggregations...");
|
|
49
|
+
async.forEachOf(
|
|
50
|
+
aggregations,
|
|
51
|
+
function (item, i, cb) {
|
|
52
|
+
log("Running aggregation " + i + "...");
|
|
53
|
+
db.collection(item.collection).aggregate(item.pipeline, function (err, result) {
|
|
54
|
+
if (err) {
|
|
55
|
+
log("Error running aggregation " + i + ".");
|
|
56
|
+
log(err.stack)
|
|
57
|
+
} else {
|
|
58
|
+
log("Done running aggregation " + i + ".");
|
|
59
|
+
}
|
|
60
|
+
cb();
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
function (err) {
|
|
64
|
+
if (err) {
|
|
65
|
+
log("Untrapped error.");
|
|
66
|
+
log(err.stack);
|
|
67
|
+
} else {
|
|
68
|
+
log("Finished running all aggregations.")
|
|
69
|
+
}
|
|
70
|
+
log("Closing database...");
|
|
71
|
+
db.close();
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
var aggregations = [
|
|
79
|
+
// ========== 1 ==========
|
|
80
|
+
{
|
|
81
|
+
collection: "tlogs",
|
|
82
|
+
pipeline: [
|
|
83
|
+
{
|
|
84
|
+
"$match": {
|
|
85
|
+
"_type": "tlog",
|
|
86
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
87
|
+
"businessDate": {
|
|
88
|
+
"$gte": ISODate("2015-11-01T00:00:00.000+0000"),
|
|
89
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"$unwind": "$order"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"$unwind": "$order.orderedOffers"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"$redact": {
|
|
101
|
+
"$cond": {
|
|
102
|
+
"if": {
|
|
103
|
+
"$not": "$order.orderedOffers.onTheHouse"
|
|
104
|
+
},
|
|
105
|
+
"then": "$$KEEP",
|
|
106
|
+
"else": "$$PRUNE"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"$redact": {
|
|
112
|
+
"$cond": {
|
|
113
|
+
"if": {
|
|
114
|
+
"$not": "$order.orderedOffers.cancellation"
|
|
115
|
+
},
|
|
116
|
+
"then": "$$KEEP",
|
|
117
|
+
"else": "$$PRUNE"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"$group": {
|
|
123
|
+
"_id": "$order.orderedOffers.offer",
|
|
124
|
+
"offer": {
|
|
125
|
+
"$first": "$order.orderedOffers.offer"
|
|
126
|
+
},
|
|
127
|
+
"menu": {
|
|
128
|
+
"$first": "$order.orderedOffers.menu"
|
|
129
|
+
},
|
|
130
|
+
"totalAmount": {
|
|
131
|
+
"$sum": "$order.orderedOffers.amount"
|
|
132
|
+
},
|
|
133
|
+
"totalCount": {
|
|
134
|
+
"$sum": NumberInt(1)
|
|
135
|
+
},
|
|
136
|
+
"totalDiners": {
|
|
137
|
+
"$sum": "$diners"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
// ========== 2 ==========
|
|
144
|
+
{
|
|
145
|
+
collection: "tlogs",
|
|
146
|
+
pipeline: [
|
|
147
|
+
{
|
|
148
|
+
"$match": {
|
|
149
|
+
"_type": "tlog",
|
|
150
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
151
|
+
"businessDate": {
|
|
152
|
+
"$gte": ISODate("2015-11-01T00:00:00.000+0000"),
|
|
153
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"$unwind": "$order"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"$unwind": "$order.orderedItems"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"$redact": {
|
|
165
|
+
"$cond": {
|
|
166
|
+
"if": {
|
|
167
|
+
"$not": "$order.orderedItems.onTheHouse"
|
|
168
|
+
},
|
|
169
|
+
"then": "$$PRUNE",
|
|
170
|
+
"else": "$$KEEP"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"$group": {
|
|
176
|
+
"_id": {
|
|
177
|
+
"category": "$order.orderedItems.category"
|
|
178
|
+
},
|
|
179
|
+
"totalItems": {
|
|
180
|
+
"$sum": NumberInt(1)
|
|
181
|
+
},
|
|
182
|
+
"totalAmount": {
|
|
183
|
+
"$sum": "$order.orderedItems.price"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
// ========== 3 ==========
|
|
190
|
+
{
|
|
191
|
+
collection: "tlogs",
|
|
192
|
+
pipeline: [
|
|
193
|
+
{
|
|
194
|
+
"$match": {
|
|
195
|
+
"_type": "tlog",
|
|
196
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
197
|
+
"businessDate": {
|
|
198
|
+
"$gte": ISODate("2015-11-01T00:00:00.000+0000"),
|
|
199
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
200
|
+
},
|
|
201
|
+
"order": {
|
|
202
|
+
"$elemMatch": {
|
|
203
|
+
"onTheHouse": null
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"$unwind": "$order"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"$unwind": "$order.tips"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"$project": {
|
|
216
|
+
"_id": "$order.tips._id",
|
|
217
|
+
"tableTip": {
|
|
218
|
+
"$cond": [
|
|
219
|
+
{
|
|
220
|
+
"$eq": [
|
|
221
|
+
{
|
|
222
|
+
"$size": {
|
|
223
|
+
"$setIntersection": [
|
|
224
|
+
"$order.tableIds",
|
|
225
|
+
[
|
|
226
|
+
ObjectId("53eb1ee4e6c77111203d852e"),
|
|
227
|
+
ObjectId("53eb1ee4e6c77111203d852f"),
|
|
228
|
+
ObjectId("53eb1ee4e6c77111203d8530"),
|
|
229
|
+
ObjectId("53eb1ee4e6c77111203d8531"),
|
|
230
|
+
ObjectId("53eb1ee4e6c77111203d8532"),
|
|
231
|
+
ObjectId("53eb1ee4e6c77111203d8533"),
|
|
232
|
+
ObjectId("53eb1ee4e6c77111203d8534"),
|
|
233
|
+
ObjectId("53eb1ee4e6c77111203d8535"),
|
|
234
|
+
ObjectId("53eb1ee4e6c77111203d8536"),
|
|
235
|
+
ObjectId("53eb1ee4e6c77111203d8537"),
|
|
236
|
+
ObjectId("53eb1ee4e6c77111203d8538"),
|
|
237
|
+
ObjectId("53eb1ee4e6c77111203d8539"),
|
|
238
|
+
ObjectId("53eb1ee4e6c77111203d853a"),
|
|
239
|
+
ObjectId("53eb1ee4e6c77111203d853b"),
|
|
240
|
+
ObjectId("53eb1ee4e6c77111203d853c"),
|
|
241
|
+
ObjectId("53eb1ee4e6c77111203d853d"),
|
|
242
|
+
ObjectId("53eb1ee4e6c77111203d853e"),
|
|
243
|
+
ObjectId("53eb1ee4e6c77111203d853f"),
|
|
244
|
+
ObjectId("53eb1ee4e6c77111203d8540"),
|
|
245
|
+
ObjectId("53eb1ee4e6c77111203d8541"),
|
|
246
|
+
ObjectId("53eb1ee4e6c77111203d8542"),
|
|
247
|
+
ObjectId("53eb1ee4e6c77111203d8543"),
|
|
248
|
+
ObjectId("53eb1ee4e6c77111203d8544"),
|
|
249
|
+
ObjectId("53eb1ee4e6c77111203d8545"),
|
|
250
|
+
ObjectId("53eb1ee4e6c77111203d8546"),
|
|
251
|
+
ObjectId("53eb1ee4e6c77111203d8547"),
|
|
252
|
+
ObjectId("53eb1ee4e6c77111203d8548"),
|
|
253
|
+
ObjectId("53eb1ee4e6c77111203d8549"),
|
|
254
|
+
ObjectId("53eb1ee4e6c77111203d854a"),
|
|
255
|
+
ObjectId("53eb1ee4e6c77111203d854b"),
|
|
256
|
+
ObjectId("53eb1ee4e6c77111203d854c"),
|
|
257
|
+
ObjectId("53eb1ee4e6c77111203d854d"),
|
|
258
|
+
ObjectId("53eb1ee4e6c77111203d854e"),
|
|
259
|
+
ObjectId("53eb1ee4e6c77111203d854f"),
|
|
260
|
+
ObjectId("53eb1ee4e6c77111203d8550"),
|
|
261
|
+
ObjectId("53eb1ee4e6c77111203d8551"),
|
|
262
|
+
ObjectId("53eb1ee4e6c77111203d8552"),
|
|
263
|
+
ObjectId("53eb1ee4e6c77111203d8553"),
|
|
264
|
+
ObjectId("53eb1ee4e6c77111203d8554"),
|
|
265
|
+
ObjectId("53eb1ee4e6c77111203d8555")
|
|
266
|
+
]
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
NumberInt(0)
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
false,
|
|
274
|
+
true
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
"amount": "$order.tips.amount"
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"$group": {
|
|
282
|
+
"_id": "$tableTip",
|
|
283
|
+
"tableTip": {
|
|
284
|
+
"$first": "$tableTip"
|
|
285
|
+
},
|
|
286
|
+
"totalAmount": {
|
|
287
|
+
"$sum": "$amount"
|
|
288
|
+
},
|
|
289
|
+
"totalCount": {
|
|
290
|
+
"$sum": NumberInt(1)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
},
|
|
296
|
+
// ========== 4 ==========
|
|
297
|
+
{
|
|
298
|
+
collection: "tlogs",
|
|
299
|
+
pipeline: [
|
|
300
|
+
{
|
|
301
|
+
"$match": {
|
|
302
|
+
"_type": "tlog",
|
|
303
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
304
|
+
"businessDate": {
|
|
305
|
+
"$gte": ISODate("2015-11-01T00:00:00.000+0000"),
|
|
306
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"$unwind": "$order"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"$group": {
|
|
315
|
+
"_id": {
|
|
316
|
+
"orderType": "$order.orderType"
|
|
317
|
+
},
|
|
318
|
+
"orderType": {
|
|
319
|
+
"$first": "$order.orderType"
|
|
320
|
+
},
|
|
321
|
+
"diners": {
|
|
322
|
+
"$sum": "$diners"
|
|
323
|
+
},
|
|
324
|
+
"totalCount": {
|
|
325
|
+
"$sum": NumberInt(1)
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
},
|
|
331
|
+
// 5, 6, and 7 deleted by Akira just to reduce character count within this JIRA comment.
|
|
332
|
+
// ========== 8 ==========
|
|
333
|
+
{
|
|
334
|
+
collection: "tlogs",
|
|
335
|
+
pipeline: [
|
|
336
|
+
{
|
|
337
|
+
"$match": {
|
|
338
|
+
"_type": "tlog",
|
|
339
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
340
|
+
"businessDate": {
|
|
341
|
+
"$gte": ISODate("2015-10-01T00:00:00.000+0000"),
|
|
342
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"$unwind": "$order"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"$unwind": "$order.orderedItems"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"$redact": {
|
|
354
|
+
"$cond": {
|
|
355
|
+
"if": {
|
|
356
|
+
"$and": [
|
|
357
|
+
{
|
|
358
|
+
"$not": "$order.orderedItems.cancellation"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"$not": "$order.orderedItems.onTheHouse"
|
|
362
|
+
}
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
"then": "$$KEEP",
|
|
366
|
+
"else": "$$KEEP"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"$unwind": "$order.orderedItems.selectedModifiers"
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"$group": {
|
|
375
|
+
"_id": {
|
|
376
|
+
"category": "$order.orderedItems.category"
|
|
377
|
+
},
|
|
378
|
+
"totalAmount": {
|
|
379
|
+
"$sum": "$order.orderedItems.selectedModifiers.price"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
]
|
|
384
|
+
},
|
|
385
|
+
// ========== 9 ==========
|
|
386
|
+
{
|
|
387
|
+
collection: "tlogs",
|
|
388
|
+
pipeline: [
|
|
389
|
+
{
|
|
390
|
+
"$match": {
|
|
391
|
+
"_type": "tlog",
|
|
392
|
+
"organization": ObjectId("53eb1ee2e6c77111203d8503"),
|
|
393
|
+
"businessDate": {
|
|
394
|
+
"$gte": ISODate("2015-10-01T00:00:00.000+0000"),
|
|
395
|
+
"$lt": ISODate("2015-11-28T23:59:59.999+0000")
|
|
396
|
+
},
|
|
397
|
+
"order.orderType": "Refund"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"$unwind": "$order"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"$unwind": "$order.payments"
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"$group": {
|
|
408
|
+
"_id": null,
|
|
409
|
+
"totalCount": {
|
|
410
|
+
"$sum": NumberInt(1)
|
|
411
|
+
},
|
|
412
|
+
"totalAmount": {
|
|
413
|
+
"$sum": "$order.payments.amount"
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
]
|
|
418
|
+
}
|
|
419
|
+
];
|
|
420
|
+
|
|
421
|
+
function ISODate(x) {
|
|
422
|
+
return new Date(x);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function NumberInt(x) {
|
|
426
|
+
return x;
|
|
427
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "MongoDB legacy driver emulation layer on top of mongodb-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"legacy"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"mongodb-core": "1.2.
|
|
16
|
+
"mongodb-core": "1.2.30"
|
|
17
17
|
, "readable-stream": "1.0.31"
|
|
18
18
|
, "es6-promise": "3.0.2"
|
|
19
19
|
},
|
package/test.js
ADDED