mongodb 3.0.6 → 3.0.7
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/CODE_OF_CONDUCT.md +80 -0
- package/CONTRIBUTING.md +29 -0
- package/HISTORY.md +5 -0
- package/conf.json +0 -1
- package/lib/admin.js +6 -49
- package/lib/aggregation_cursor.js +4 -45
- package/lib/bulk/common.js +0 -23
- package/lib/bulk/ordered.js +15 -22
- package/lib/bulk/unordered.js +15 -22
- package/lib/collection.js +57 -180
- package/lib/command_cursor.js +5 -32
- package/lib/cursor.js +13 -82
- package/lib/db.js +38 -117
- package/lib/gridfs/grid_store.js +12 -61
- package/lib/mongo_client.js +16 -27
- package/lib/topologies/mongos.js +10 -38
- package/lib/topologies/replset.js +10 -37
- package/lib/topologies/server.js +9 -37
- package/lib/utils.js +48 -2
- package/package.json +2 -2
- package/yarn.lock +28 -24
- package/lib/metadata.js +0 -70
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
## Code of Conduct
|
|
2
|
+
|
|
3
|
+
### Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age,
|
|
8
|
+
body size, disability, ethnicity, gender identity and expression, level of
|
|
9
|
+
experience, nationality, personal appearance, race, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
Please also take a moment to review [MongoDB's core values][mdb-core-values].
|
|
13
|
+
|
|
14
|
+
### Our Standards
|
|
15
|
+
|
|
16
|
+
Examples of behavior that contributes to creating a positive environment
|
|
17
|
+
include:
|
|
18
|
+
|
|
19
|
+
* Using welcoming and inclusive language
|
|
20
|
+
* Being respectful of differing viewpoints and experiences
|
|
21
|
+
* Gracefully accepting constructive criticism
|
|
22
|
+
* Focusing on what is best for the community
|
|
23
|
+
* Showing empathy towards other community members
|
|
24
|
+
|
|
25
|
+
Examples of unacceptable behavior by participants include:
|
|
26
|
+
|
|
27
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
28
|
+
advances
|
|
29
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
30
|
+
* Public or private harassment
|
|
31
|
+
* Publishing others' private information, such as a physical or electronic
|
|
32
|
+
address, without explicit permission
|
|
33
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
34
|
+
professional setting
|
|
35
|
+
|
|
36
|
+
### Our Responsibilities
|
|
37
|
+
|
|
38
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
39
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
40
|
+
response to any instances of unacceptable behavior.
|
|
41
|
+
|
|
42
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
43
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
44
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
45
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
46
|
+
threatening, offensive, or harmful.
|
|
47
|
+
|
|
48
|
+
### Scope
|
|
49
|
+
|
|
50
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
51
|
+
when an individual is representing the project or its community. Examples of
|
|
52
|
+
representing a project or community include using an official project e-mail
|
|
53
|
+
address, posting via an official social media account, or acting as an
|
|
54
|
+
appointed representative at an online or offline event. Representation of a
|
|
55
|
+
project may be further defined and clarified by project maintainers.
|
|
56
|
+
|
|
57
|
+
### Enforcement
|
|
58
|
+
|
|
59
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
60
|
+
reported by contacting the project team, or by
|
|
61
|
+
[contacting GitHub][github-report-abuse]. All complaints will be reviewed
|
|
62
|
+
and investigated and will result in a response that is deemed necessary and
|
|
63
|
+
appropriate to the circumstances. The project team is obligated to maintain
|
|
64
|
+
confidentiality with regard to the reporter of an incident.
|
|
65
|
+
Further details of specific enforcement policies may be posted separately.
|
|
66
|
+
|
|
67
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
68
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
69
|
+
members of the project's leadership.
|
|
70
|
+
|
|
71
|
+
### Attribution
|
|
72
|
+
|
|
73
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
74
|
+
version [1.4][version].
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
[github-report-abuse]: https://github.com/contact/report-abuse
|
|
78
|
+
[homepage]: https://www.contributor-covenant.org/
|
|
79
|
+
[mdb-core-values]: https://www.mongodb.com/company/
|
|
80
|
+
[version]: https://www.contributor-covenant.org/version/1/4/
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
When contributing to this repository, please first discuss the change you wish
|
|
4
|
+
to make via issue, pull request, or any other method with the owners of this
|
|
5
|
+
repository before making a change.
|
|
6
|
+
|
|
7
|
+
Please note we have a [code of conduct][code-of-conduct],
|
|
8
|
+
please follow it in all your interactions with the project.
|
|
9
|
+
|
|
10
|
+
## Commit messages
|
|
11
|
+
|
|
12
|
+
Please follow the [Angular commit style][angular-commit-style].
|
|
13
|
+
This helps the team automate [CHANGELOG.md][changelog] generation.
|
|
14
|
+
|
|
15
|
+
## Pull Request Process
|
|
16
|
+
|
|
17
|
+
1. Update the README.md or similar documentation with details of changes you
|
|
18
|
+
wish to make, if applicable.
|
|
19
|
+
2. Add any appropriate tests.
|
|
20
|
+
3. Make your code or other changes.
|
|
21
|
+
4. Review guidelines such as
|
|
22
|
+
[How to write the perfect pull request][github-perfect-pr], thanks!
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
[angular-commit-style]: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits
|
|
26
|
+
[changelog]: CHANGELOG.md
|
|
27
|
+
[code-of-conduct]: CODE_OF_CONDUCT.md
|
|
28
|
+
[github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/
|
|
29
|
+
[mdb-core-values]: https://www.mongodb.com/company/
|
package/HISTORY.md
CHANGED
package/conf.json
CHANGED
package/lib/admin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const toError = require('./utils').toError;
|
|
4
|
+
const shallowClone = require('./utils').shallowClone;
|
|
5
|
+
const executeOperation = require('./utils').executeOperation;
|
|
6
|
+
const applyWriteConcern = require('./utils').applyWriteConcern;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @fileOverview The **Admin** class is an internal class that allows convenient access to
|
|
@@ -48,8 +48,6 @@ var Admin = function(db, topology, promiseLibrary) {
|
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
var define = (Admin.define = new Define('Admin', Admin, false));
|
|
52
|
-
|
|
53
51
|
/**
|
|
54
52
|
* The callback format for results
|
|
55
53
|
* @callback Admin~resultCallback
|
|
@@ -79,8 +77,6 @@ Admin.prototype.command = function(command, options, callback) {
|
|
|
79
77
|
]);
|
|
80
78
|
};
|
|
81
79
|
|
|
82
|
-
define.classMethod('command', { callback: true, promise: true });
|
|
83
|
-
|
|
84
80
|
/**
|
|
85
81
|
* Retrieve the server information for the current
|
|
86
82
|
* instance of the db client
|
|
@@ -102,8 +98,6 @@ Admin.prototype.buildInfo = function(options, callback) {
|
|
|
102
98
|
]);
|
|
103
99
|
};
|
|
104
100
|
|
|
105
|
-
define.classMethod('buildInfo', { callback: true, promise: true });
|
|
106
|
-
|
|
107
101
|
/**
|
|
108
102
|
* Retrieve the server information for the current
|
|
109
103
|
* instance of the db client
|
|
@@ -125,8 +119,6 @@ Admin.prototype.serverInfo = function(options, callback) {
|
|
|
125
119
|
]);
|
|
126
120
|
};
|
|
127
121
|
|
|
128
|
-
define.classMethod('serverInfo', { callback: true, promise: true });
|
|
129
|
-
|
|
130
122
|
/**
|
|
131
123
|
* Retrieve this db's server status.
|
|
132
124
|
*
|
|
@@ -153,8 +145,6 @@ var serverStatus = function(self, options, callback) {
|
|
|
153
145
|
});
|
|
154
146
|
};
|
|
155
147
|
|
|
156
|
-
define.classMethod('serverStatus', { callback: true, promise: true });
|
|
157
|
-
|
|
158
148
|
/**
|
|
159
149
|
* Ping the MongoDB server and retrieve results
|
|
160
150
|
*
|
|
@@ -175,29 +165,6 @@ Admin.prototype.ping = function(options, callback) {
|
|
|
175
165
|
]);
|
|
176
166
|
};
|
|
177
167
|
|
|
178
|
-
define.classMethod('ping', { callback: true, promise: true });
|
|
179
|
-
|
|
180
|
-
// Get write concern
|
|
181
|
-
var writeConcern = function(options, db) {
|
|
182
|
-
options = shallowClone(options);
|
|
183
|
-
|
|
184
|
-
// If options already contain write concerns return it
|
|
185
|
-
if (options.w || options.wtimeout || options.j || options.fsync) {
|
|
186
|
-
return options;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Set db write concern if available
|
|
190
|
-
if (db.writeConcern) {
|
|
191
|
-
if (options.w) options.w = db.writeConcern.w;
|
|
192
|
-
if (options.wtimeout) options.wtimeout = db.writeConcern.wtimeout;
|
|
193
|
-
if (options.j) options.j = db.writeConcern.j;
|
|
194
|
-
if (options.fsync) options.fsync = db.writeConcern.fsync;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Return modified options
|
|
198
|
-
return options;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
168
|
/**
|
|
202
169
|
* Add a user to the database.
|
|
203
170
|
* @method
|
|
@@ -222,7 +189,7 @@ Admin.prototype.addUser = function(username, password, options, callback) {
|
|
|
222
189
|
options = args.length ? args.shift() : {};
|
|
223
190
|
options = options || {};
|
|
224
191
|
// Get the options
|
|
225
|
-
options =
|
|
192
|
+
options = applyWriteConcern(shallowClone(options), { db: self.s.db });
|
|
226
193
|
// Set the db name to admin
|
|
227
194
|
options.dbName = 'admin';
|
|
228
195
|
|
|
@@ -234,8 +201,6 @@ Admin.prototype.addUser = function(username, password, options, callback) {
|
|
|
234
201
|
]);
|
|
235
202
|
};
|
|
236
203
|
|
|
237
|
-
define.classMethod('addUser', { callback: true, promise: true });
|
|
238
|
-
|
|
239
204
|
/**
|
|
240
205
|
* Remove a user from a database
|
|
241
206
|
* @method
|
|
@@ -257,7 +222,7 @@ Admin.prototype.removeUser = function(username, options, callback) {
|
|
|
257
222
|
options = args.length ? args.shift() : {};
|
|
258
223
|
options = options || {};
|
|
259
224
|
// Get the options
|
|
260
|
-
options =
|
|
225
|
+
options = applyWriteConcern(shallowClone(options), { db: self.s.db });
|
|
261
226
|
// Set the db name
|
|
262
227
|
options.dbName = 'admin';
|
|
263
228
|
|
|
@@ -268,8 +233,6 @@ Admin.prototype.removeUser = function(username, options, callback) {
|
|
|
268
233
|
]);
|
|
269
234
|
};
|
|
270
235
|
|
|
271
|
-
define.classMethod('removeUser', { callback: true, promise: true });
|
|
272
|
-
|
|
273
236
|
/**
|
|
274
237
|
* Validate an existing collection
|
|
275
238
|
*
|
|
@@ -317,8 +280,6 @@ var validateCollection = function(self, collectionName, options, callback) {
|
|
|
317
280
|
});
|
|
318
281
|
};
|
|
319
282
|
|
|
320
|
-
define.classMethod('validateCollection', { callback: true, promise: true });
|
|
321
|
-
|
|
322
283
|
/**
|
|
323
284
|
* List the available databases
|
|
324
285
|
*
|
|
@@ -341,8 +302,6 @@ Admin.prototype.listDatabases = function(options, callback) {
|
|
|
341
302
|
]);
|
|
342
303
|
};
|
|
343
304
|
|
|
344
|
-
define.classMethod('listDatabases', { callback: true, promise: true });
|
|
345
|
-
|
|
346
305
|
/**
|
|
347
306
|
* Get ReplicaSet status
|
|
348
307
|
*
|
|
@@ -366,6 +325,4 @@ var replSetGetStatus = function(self, options, callback) {
|
|
|
366
325
|
});
|
|
367
326
|
};
|
|
368
327
|
|
|
369
|
-
define.classMethod('replSetGetStatus', { callback: true, promise: true });
|
|
370
|
-
|
|
371
328
|
module.exports = Admin;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
CoreCursor = require('./cursor');
|
|
3
|
+
const inherits = require('util').inherits;
|
|
4
|
+
const MongoError = require('mongodb-core').MongoError;
|
|
5
|
+
const Readable = require('stream').Readable;
|
|
6
|
+
const CoreCursor = require('./cursor');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @fileOverview The **AggregationCursor** class is an internal class that embodies an aggregation cursor on MongoDB
|
|
@@ -131,8 +130,6 @@ for (var name in CoreCursor.prototype) {
|
|
|
131
130
|
AggregationCursor.prototype[name] = CoreCursor.prototype[name];
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
var define = (AggregationCursor.define = new Define('AggregationCursor', AggregationCursor, true));
|
|
135
|
-
|
|
136
133
|
/**
|
|
137
134
|
* Set the batch size for the cursor.
|
|
138
135
|
* @method
|
|
@@ -150,8 +147,6 @@ AggregationCursor.prototype.batchSize = function(value) {
|
|
|
150
147
|
return this;
|
|
151
148
|
};
|
|
152
149
|
|
|
153
|
-
define.classMethod('batchSize', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
154
|
-
|
|
155
150
|
/**
|
|
156
151
|
* Add a geoNear stage to the aggregation pipeline
|
|
157
152
|
* @method
|
|
@@ -163,8 +158,6 @@ AggregationCursor.prototype.geoNear = function(document) {
|
|
|
163
158
|
return this;
|
|
164
159
|
};
|
|
165
160
|
|
|
166
|
-
define.classMethod('geoNear', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
167
|
-
|
|
168
161
|
/**
|
|
169
162
|
* Add a group stage to the aggregation pipeline
|
|
170
163
|
* @method
|
|
@@ -176,8 +169,6 @@ AggregationCursor.prototype.group = function(document) {
|
|
|
176
169
|
return this;
|
|
177
170
|
};
|
|
178
171
|
|
|
179
|
-
define.classMethod('group', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
180
|
-
|
|
181
172
|
/**
|
|
182
173
|
* Add a limit stage to the aggregation pipeline
|
|
183
174
|
* @method
|
|
@@ -189,8 +180,6 @@ AggregationCursor.prototype.limit = function(value) {
|
|
|
189
180
|
return this;
|
|
190
181
|
};
|
|
191
182
|
|
|
192
|
-
define.classMethod('limit', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
193
|
-
|
|
194
183
|
/**
|
|
195
184
|
* Add a match stage to the aggregation pipeline
|
|
196
185
|
* @method
|
|
@@ -202,8 +191,6 @@ AggregationCursor.prototype.match = function(document) {
|
|
|
202
191
|
return this;
|
|
203
192
|
};
|
|
204
193
|
|
|
205
|
-
define.classMethod('match', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
206
|
-
|
|
207
194
|
/**
|
|
208
195
|
* Add a maxTimeMS stage to the aggregation pipeline
|
|
209
196
|
* @method
|
|
@@ -217,8 +204,6 @@ AggregationCursor.prototype.maxTimeMS = function(value) {
|
|
|
217
204
|
return this;
|
|
218
205
|
};
|
|
219
206
|
|
|
220
|
-
define.classMethod('maxTimeMS', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
221
|
-
|
|
222
207
|
/**
|
|
223
208
|
* Add a out stage to the aggregation pipeline
|
|
224
209
|
* @method
|
|
@@ -230,8 +215,6 @@ AggregationCursor.prototype.out = function(destination) {
|
|
|
230
215
|
return this;
|
|
231
216
|
};
|
|
232
217
|
|
|
233
|
-
define.classMethod('out', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
234
|
-
|
|
235
218
|
/**
|
|
236
219
|
* Add a project stage to the aggregation pipeline
|
|
237
220
|
* @method
|
|
@@ -243,8 +226,6 @@ AggregationCursor.prototype.project = function(document) {
|
|
|
243
226
|
return this;
|
|
244
227
|
};
|
|
245
228
|
|
|
246
|
-
define.classMethod('project', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
247
|
-
|
|
248
229
|
/**
|
|
249
230
|
* Add a lookup stage to the aggregation pipeline
|
|
250
231
|
* @method
|
|
@@ -256,8 +237,6 @@ AggregationCursor.prototype.lookup = function(document) {
|
|
|
256
237
|
return this;
|
|
257
238
|
};
|
|
258
239
|
|
|
259
|
-
define.classMethod('lookup', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
260
|
-
|
|
261
240
|
/**
|
|
262
241
|
* Add a redact stage to the aggregation pipeline
|
|
263
242
|
* @method
|
|
@@ -269,8 +248,6 @@ AggregationCursor.prototype.redact = function(document) {
|
|
|
269
248
|
return this;
|
|
270
249
|
};
|
|
271
250
|
|
|
272
|
-
define.classMethod('redact', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
273
|
-
|
|
274
251
|
/**
|
|
275
252
|
* Add a skip stage to the aggregation pipeline
|
|
276
253
|
* @method
|
|
@@ -282,8 +259,6 @@ AggregationCursor.prototype.skip = function(value) {
|
|
|
282
259
|
return this;
|
|
283
260
|
};
|
|
284
261
|
|
|
285
|
-
define.classMethod('skip', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
286
|
-
|
|
287
262
|
/**
|
|
288
263
|
* Add a sort stage to the aggregation pipeline
|
|
289
264
|
* @method
|
|
@@ -295,8 +270,6 @@ AggregationCursor.prototype.sort = function(document) {
|
|
|
295
270
|
return this;
|
|
296
271
|
};
|
|
297
272
|
|
|
298
|
-
define.classMethod('sort', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
299
|
-
|
|
300
273
|
/**
|
|
301
274
|
* Add a unwind stage to the aggregation pipeline
|
|
302
275
|
* @method
|
|
@@ -308,22 +281,8 @@ AggregationCursor.prototype.unwind = function(field) {
|
|
|
308
281
|
return this;
|
|
309
282
|
};
|
|
310
283
|
|
|
311
|
-
define.classMethod('unwind', { callback: false, promise: false, returns: [AggregationCursor] });
|
|
312
|
-
|
|
313
284
|
AggregationCursor.prototype.get = AggregationCursor.prototype.toArray;
|
|
314
285
|
|
|
315
|
-
// Inherited methods
|
|
316
|
-
define.classMethod('toArray', { callback: true, promise: true });
|
|
317
|
-
define.classMethod('each', { callback: true, promise: false });
|
|
318
|
-
define.classMethod('forEach', { callback: true, promise: false });
|
|
319
|
-
define.classMethod('hasNext', { callback: true, promise: true });
|
|
320
|
-
define.classMethod('next', { callback: true, promise: true });
|
|
321
|
-
define.classMethod('close', { callback: true, promise: true });
|
|
322
|
-
define.classMethod('isClosed', { callback: false, promise: false, returns: [Boolean] });
|
|
323
|
-
define.classMethod('rewind', { callback: false, promise: false });
|
|
324
|
-
define.classMethod('bufferedCount', { callback: false, promise: false, returns: [Number] });
|
|
325
|
-
define.classMethod('readBufferedDocuments', { callback: false, promise: false, returns: [Array] });
|
|
326
|
-
|
|
327
286
|
/**
|
|
328
287
|
* Get the next available document from the cursor, returns null if no more documents are available.
|
|
329
288
|
* @function AggregationCursor.prototype.next
|
package/lib/bulk/common.js
CHANGED
|
@@ -15,28 +15,6 @@ var INSERT = 1;
|
|
|
15
15
|
var UPDATE = 2;
|
|
16
16
|
var REMOVE = 3;
|
|
17
17
|
|
|
18
|
-
// Get write concern
|
|
19
|
-
var writeConcern = function(target, col, options) {
|
|
20
|
-
var writeConcern = {};
|
|
21
|
-
|
|
22
|
-
// Collection level write concern
|
|
23
|
-
if (col.writeConcern && col.writeConcern.w != null) writeConcern.w = col.writeConcern.w;
|
|
24
|
-
if (col.writeConcern && col.writeConcern.j != null) writeConcern.j = col.writeConcern.j;
|
|
25
|
-
if (col.writeConcern && col.writeConcern.fsync != null)
|
|
26
|
-
writeConcern.fsync = col.writeConcern.fsync;
|
|
27
|
-
if (col.writeConcern && col.writeConcern.wtimeout != null)
|
|
28
|
-
writeConcern.wtimeout = col.writeConcern.wtimeout;
|
|
29
|
-
|
|
30
|
-
// Options level write concern
|
|
31
|
-
if (options && options.w != null) writeConcern.w = options.w;
|
|
32
|
-
if (options && options.wtimeout != null) writeConcern.wtimeout = options.wtimeout;
|
|
33
|
-
if (options && options.j != null) writeConcern.j = options.j;
|
|
34
|
-
if (options && options.fsync != null) writeConcern.fsync = options.fsync;
|
|
35
|
-
|
|
36
|
-
// Return write concern
|
|
37
|
-
return writeConcern;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
18
|
/**
|
|
41
19
|
* Helper function to define properties
|
|
42
20
|
* @ignore
|
|
@@ -455,7 +433,6 @@ exports.Batch = Batch;
|
|
|
455
433
|
exports.LegacyOp = LegacyOp;
|
|
456
434
|
exports.mergeBatchResults = mergeBatchResults;
|
|
457
435
|
exports.cloneOptions = cloneOptions;
|
|
458
|
-
exports.writeConcern = writeConcern;
|
|
459
436
|
exports.INVALID_BSON_ERROR = INVALID_BSON_ERROR;
|
|
460
437
|
exports.WRITE_CONCERN_ERROR = WRITE_CONCERN_ERROR;
|
|
461
438
|
exports.MULTIPLE_ERROR = MULTIPLE_ERROR;
|
package/lib/bulk/ordered.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
const common = require('./common');
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
const toError = require('../utils').toError;
|
|
6
|
+
const handleCallback = require('../utils').handleCallback;
|
|
7
|
+
const shallowClone = utils.shallowClone;
|
|
8
|
+
const BulkWriteResult = common.BulkWriteResult;
|
|
9
|
+
const ObjectID = require('mongodb-core').BSON.ObjectID;
|
|
10
|
+
const BSON = require('mongodb-core').BSON;
|
|
11
|
+
const Batch = common.Batch;
|
|
12
|
+
const mergeBatchResults = common.mergeBatchResults;
|
|
13
|
+
const executeOperation = utils.executeOperation;
|
|
14
|
+
const BulkWriteError = require('./common').BulkWriteError;
|
|
15
|
+
const applyWriteConcern = utils.applyWriteConcern;
|
|
16
16
|
|
|
17
17
|
var bson = new BSON([
|
|
18
18
|
BSON.Binary,
|
|
@@ -247,7 +247,8 @@ function OrderedBulkOperation(topology, collection, options) {
|
|
|
247
247
|
: 1000;
|
|
248
248
|
|
|
249
249
|
// Get the write concern
|
|
250
|
-
var writeConcern =
|
|
250
|
+
var writeConcern = applyWriteConcern(shallowClone(options), { collection: collection }, options);
|
|
251
|
+
writeConcern = writeConcern.writeConcern;
|
|
251
252
|
|
|
252
253
|
// Get the promiseLibrary
|
|
253
254
|
var promiseLibrary = options.promiseLibrary || Promise;
|
|
@@ -309,12 +310,6 @@ function OrderedBulkOperation(topology, collection, options) {
|
|
|
309
310
|
};
|
|
310
311
|
}
|
|
311
312
|
|
|
312
|
-
var define = (OrderedBulkOperation.define = new Define(
|
|
313
|
-
'OrderedBulkOperation',
|
|
314
|
-
OrderedBulkOperation,
|
|
315
|
-
false
|
|
316
|
-
));
|
|
317
|
-
|
|
318
313
|
OrderedBulkOperation.prototype.raw = function(op) {
|
|
319
314
|
var key = Object.keys(op)[0];
|
|
320
315
|
|
|
@@ -602,8 +597,6 @@ OrderedBulkOperation.prototype.execute = function(_writeConcern, options, callba
|
|
|
602
597
|
return executeOperation(this.s.topology, executeCommands, [this, options, callback]);
|
|
603
598
|
};
|
|
604
599
|
|
|
605
|
-
define.classMethod('execute', { callback: true, promise: false });
|
|
606
|
-
|
|
607
600
|
/**
|
|
608
601
|
* Returns an unordered batch object
|
|
609
602
|
* @ignore
|
package/lib/bulk/unordered.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
const common = require('./common');
|
|
4
|
+
const utils = require('../utils');
|
|
5
|
+
const toError = require('../utils').toError;
|
|
6
|
+
const handleCallback = require('../utils').handleCallback;
|
|
7
|
+
const shallowClone = utils.shallowClone;
|
|
8
|
+
const BulkWriteResult = common.BulkWriteResult;
|
|
9
|
+
const ObjectID = require('mongodb-core').BSON.ObjectID;
|
|
10
|
+
const BSON = require('mongodb-core').BSON;
|
|
11
|
+
const Batch = common.Batch;
|
|
12
|
+
const mergeBatchResults = common.mergeBatchResults;
|
|
13
|
+
const executeOperation = utils.executeOperation;
|
|
14
|
+
const BulkWriteError = require('./common').BulkWriteError;
|
|
15
|
+
const applyWriteConcern = utils.applyWriteConcern;
|
|
16
16
|
|
|
17
17
|
var bson = new BSON([
|
|
18
18
|
BSON.Binary,
|
|
@@ -257,7 +257,8 @@ var UnorderedBulkOperation = function(topology, collection, options) {
|
|
|
257
257
|
: 1000;
|
|
258
258
|
|
|
259
259
|
// Get the write concern
|
|
260
|
-
var writeConcern =
|
|
260
|
+
var writeConcern = applyWriteConcern(shallowClone(options), { collection: collection }, options);
|
|
261
|
+
writeConcern = writeConcern.writeConcern;
|
|
261
262
|
|
|
262
263
|
// Get the promiseLibrary
|
|
263
264
|
var promiseLibrary = options.promiseLibrary || Promise;
|
|
@@ -318,12 +319,6 @@ var UnorderedBulkOperation = function(topology, collection, options) {
|
|
|
318
319
|
};
|
|
319
320
|
};
|
|
320
321
|
|
|
321
|
-
var define = (UnorderedBulkOperation.define = new Define(
|
|
322
|
-
'UnorderedBulkOperation',
|
|
323
|
-
UnorderedBulkOperation,
|
|
324
|
-
false
|
|
325
|
-
));
|
|
326
|
-
|
|
327
322
|
/**
|
|
328
323
|
* Add a single insert document to the bulk operation
|
|
329
324
|
*
|
|
@@ -616,8 +611,6 @@ UnorderedBulkOperation.prototype.execute = function(_writeConcern, options, call
|
|
|
616
611
|
return executeOperation(this.s.topology, executeBatches, [this, options, callback]);
|
|
617
612
|
};
|
|
618
613
|
|
|
619
|
-
define.classMethod('execute', { callback: true, promise: false });
|
|
620
|
-
|
|
621
614
|
/**
|
|
622
615
|
* Returns an unordered batch object
|
|
623
616
|
* @ignore
|