mongoose 5.2.3 → 5.2.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/.eslintignore +1 -0
- package/.travis.yml +1 -1
- package/History.md +58 -0
- package/README.md +6 -6
- package/lib/aggregate.js +22 -0
- package/lib/browser.js +2 -0
- package/lib/cast/boolean.js +5 -6
- package/lib/cast/number.js +49 -0
- package/lib/collection.js +2 -5
- package/lib/connection.js +22 -3
- package/lib/document.js +31 -3
- package/lib/driver.js +15 -0
- package/lib/drivers/browser/index.js +3 -0
- package/lib/drivers/node-mongodb-native/collection.js +23 -9
- package/lib/drivers/node-mongodb-native/index.js +1 -0
- package/lib/helpers/immediate.js +10 -0
- package/lib/helpers/populate/getSchemaTypes.js +80 -62
- package/lib/helpers/populate/getVirtual.js +2 -5
- package/lib/helpers/query/applyQueryMiddleware.js +37 -0
- package/lib/helpers/query/castUpdate.js +34 -12
- package/lib/index.js +6 -4
- package/lib/model.js +98 -100
- package/lib/query.js +125 -25
- package/lib/queryhelpers.js +21 -2
- package/lib/schema/boolean.js +40 -0
- package/lib/schema/documentarray.js +18 -5
- package/lib/schema/embedded.js +7 -2
- package/lib/schema/number.js +11 -31
- package/lib/schema/objectid.js +1 -4
- package/lib/schema.js +1 -1
- package/lib/schematype.js +35 -19
- package/lib/types/buffer.js +2 -2
- package/lib/types/decimal128.js +1 -1
- package/lib/types/documentarray.js +2 -2
- package/lib/types/embedded.js +2 -1
- package/lib/types/map.js +4 -0
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +2 -1
- package/lib/utils.js +17 -16
- package/migrating_to_5.md +1 -1
- package/package.json +4 -6
- package/tools/checkNodeVersion.js +7 -0
- package/tools/sharded.js +4 -1
- package/website.js +2 -1
- package/lib/drivers/index.js +0 -20
- package/lib/drivers/index.web.js +0 -5
package/lib/types/map.js
CHANGED
package/lib/types/objectid.js
CHANGED
package/lib/types/subdocument.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Document = require('../document');
|
|
4
|
+
var immediate = require('../helpers/immediate');
|
|
4
5
|
var internalToObjectOptions = require('../options').internalToObjectOptions;
|
|
5
6
|
var utils = require('../utils');
|
|
6
7
|
|
|
@@ -68,7 +69,7 @@ Subdocument.prototype.save = function(options, fn) {
|
|
|
68
69
|
*/
|
|
69
70
|
|
|
70
71
|
Subdocument.prototype.$__save = function(fn) {
|
|
71
|
-
return
|
|
72
|
+
return immediate(() => fn(null, this));
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
Subdocument.prototype.$isValid = function(path) {
|
package/lib/utils.js
CHANGED
|
@@ -8,6 +8,7 @@ const Decimal = require('./types/decimal128');
|
|
|
8
8
|
const ObjectId = require('./types/objectid');
|
|
9
9
|
const PromiseProvider = require('./promise_provider');
|
|
10
10
|
const cloneRegExp = require('regexp-clone');
|
|
11
|
+
const get = require('lodash.get');
|
|
11
12
|
const sliced = require('sliced');
|
|
12
13
|
const mpath = require('mpath');
|
|
13
14
|
const ms = require('ms');
|
|
@@ -59,8 +60,8 @@ exports.deepEqual = function deepEqual(a, b) {
|
|
|
59
60
|
return a.getTime() === b.getTime();
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
if ((a
|
|
63
|
-
(a
|
|
63
|
+
if ((isBsonType(a, 'ObjectID') && isBsonType(b, 'ObjectID')) ||
|
|
64
|
+
(isBsonType(a, 'Decimal128') && isBsonType(b, 'Decimal128'))) {
|
|
64
65
|
return a.toString() === b.toString();
|
|
65
66
|
}
|
|
66
67
|
|
|
@@ -137,6 +138,14 @@ exports.deepEqual = function deepEqual(a, b) {
|
|
|
137
138
|
return true;
|
|
138
139
|
};
|
|
139
140
|
|
|
141
|
+
/*!
|
|
142
|
+
* Get the bson type, if it exists
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
function isBsonType(obj, typename) {
|
|
146
|
+
return get(obj, '_bsontype', void 0) === typename;
|
|
147
|
+
}
|
|
148
|
+
|
|
140
149
|
/*!
|
|
141
150
|
* Get the last element of an array
|
|
142
151
|
*/
|
|
@@ -194,7 +203,7 @@ exports.clone = function clone(obj, options) {
|
|
|
194
203
|
if (obj instanceof ObjectId) {
|
|
195
204
|
return new ObjectId(obj.id);
|
|
196
205
|
}
|
|
197
|
-
if (obj
|
|
206
|
+
if (isBsonType(obj, 'Decimal128')) {
|
|
198
207
|
if (options && options.flattenDecimals) {
|
|
199
208
|
return obj.toJSON();
|
|
200
209
|
}
|
|
@@ -417,7 +426,7 @@ exports.isObject = function(arg) {
|
|
|
417
426
|
*/
|
|
418
427
|
|
|
419
428
|
exports.isPOJO = function(arg) {
|
|
420
|
-
return arg
|
|
429
|
+
return get(arg, 'constructor.name') === 'Object';
|
|
421
430
|
};
|
|
422
431
|
|
|
423
432
|
/*!
|
|
@@ -473,7 +482,10 @@ exports.isMongooseObject = function(v) {
|
|
|
473
482
|
return false;
|
|
474
483
|
}
|
|
475
484
|
|
|
476
|
-
return v.$__ != null ||
|
|
485
|
+
return v.$__ != null || // Document
|
|
486
|
+
v.isMongooseArray || // Array or Document Array
|
|
487
|
+
v.isMongooseBuffer || // Buffer
|
|
488
|
+
v.$isMongooseMap; // Map
|
|
477
489
|
};
|
|
478
490
|
var isMongooseObject = exports.isMongooseObject;
|
|
479
491
|
|
|
@@ -878,17 +890,6 @@ exports.each = function(arr, fn) {
|
|
|
878
890
|
}
|
|
879
891
|
};
|
|
880
892
|
|
|
881
|
-
/*!
|
|
882
|
-
* Centralize this so we can more easily work around issues with people
|
|
883
|
-
* stubbing out `process.nextTick()` in tests using sinon:
|
|
884
|
-
* https://github.com/sinonjs/lolex#automatically-incrementing-mocked-time
|
|
885
|
-
* See gh-6074
|
|
886
|
-
*/
|
|
887
|
-
|
|
888
|
-
exports.immediate = function immediate(cb) {
|
|
889
|
-
return process.nextTick(cb);
|
|
890
|
-
};
|
|
891
|
-
|
|
892
893
|
/*!
|
|
893
894
|
* ignore
|
|
894
895
|
*/
|
package/migrating_to_5.md
CHANGED
|
@@ -134,7 +134,7 @@ const cursorWithOptions = MyModel.
|
|
|
134
134
|
|
|
135
135
|
Due to changes in the MongoDB driver, connection strings must be URI encoded.
|
|
136
136
|
|
|
137
|
-
If they are not, connections may fail with an
|
|
137
|
+
If they are not, connections may fail with an illegal character message.
|
|
138
138
|
|
|
139
139
|
#### Passwords which contain certain characters
|
|
140
140
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongoose",
|
|
3
3
|
"description": "Mongoose MongoDB ODM",
|
|
4
|
-
"version": "5.2.
|
|
4
|
+
"version": "5.2.7",
|
|
5
5
|
"author": "Guillermo Rauch <guillermo@learnboost.com>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mongodb",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"mongodb-core": "3.1.0",
|
|
28
28
|
"mongoose-legacy-pluralize": "1.0.2",
|
|
29
29
|
"mpath": "0.4.1",
|
|
30
|
-
"mquery": "3.
|
|
30
|
+
"mquery": "3.1.2",
|
|
31
31
|
"ms": "2.0.0",
|
|
32
32
|
"regexp-clone": "0.0.1",
|
|
33
33
|
"sliced": "1.0.1"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"bluebird": "3.5.0",
|
|
42
42
|
"co": "4.6.0",
|
|
43
43
|
"dox": "0.3.1",
|
|
44
|
-
"eslint": "
|
|
44
|
+
"eslint": "5.3.0",
|
|
45
45
|
"highlight.js": "9.1.0",
|
|
46
46
|
"jade": "1.11.0",
|
|
47
47
|
"lodash": "4.17.5",
|
|
@@ -54,19 +54,17 @@
|
|
|
54
54
|
"nyc": "11.8.0",
|
|
55
55
|
"power-assert": "1.4.1",
|
|
56
56
|
"q": "1.5.1",
|
|
57
|
-
"rimraf": "2.6.2",
|
|
58
57
|
"semver": "5.5.0",
|
|
59
58
|
"tbd": "0.6.4",
|
|
60
59
|
"uuid": "2.0.3",
|
|
61
60
|
"uuid-parse": "1.0.0",
|
|
62
|
-
"webpack": "4.
|
|
61
|
+
"webpack": "4.16.4",
|
|
63
62
|
"validator": "5.4.0"
|
|
64
63
|
},
|
|
65
64
|
"directories": {
|
|
66
65
|
"lib": "./lib/mongoose"
|
|
67
66
|
},
|
|
68
67
|
"scripts": {
|
|
69
|
-
"fix-lint": "eslint . --fix",
|
|
70
68
|
"lint": "eslint . --quiet",
|
|
71
69
|
"release": "git pull && git push origin master --tags && npm publish",
|
|
72
70
|
"release-legacy": "git pull origin 4.x && git push origin 4.x --tags && npm publish --tag legacy",
|
package/tools/sharded.js
CHANGED
|
@@ -13,7 +13,7 @@ co(function*() {
|
|
|
13
13
|
|
|
14
14
|
yield topology.addShard([{
|
|
15
15
|
options: {
|
|
16
|
-
bind_ip: 'localhost', port: 31000, dbpath: `/data/db/31000
|
|
16
|
+
bind_ip: 'localhost', port: 31000, dbpath: `/data/db/31000`, shardsvr: null
|
|
17
17
|
}
|
|
18
18
|
}], { replSet: 'rs1' });
|
|
19
19
|
|
|
@@ -29,9 +29,12 @@ co(function*() {
|
|
|
29
29
|
binary: 'mongos'
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
console.log('Start...');
|
|
32
33
|
// Start up topology
|
|
33
34
|
yield topology.start();
|
|
34
35
|
|
|
36
|
+
console.log('Started');
|
|
37
|
+
|
|
35
38
|
// Shard db
|
|
36
39
|
yield topology.enableSharding('test');
|
|
37
40
|
|
package/website.js
CHANGED
|
@@ -25,7 +25,8 @@ const tests = [
|
|
|
25
25
|
...acquit.parse(fs.readFileSync('./test/webpack.test.js').toString()),
|
|
26
26
|
...acquit.parse(fs.readFileSync('./test/geojson.test.js').toString()),
|
|
27
27
|
...acquit.parse(fs.readFileSync('./test/docs/transactions.test.js').toString()),
|
|
28
|
-
...acquit.parse(fs.readFileSync('./test/schema.alias.test.js').toString())
|
|
28
|
+
...acquit.parse(fs.readFileSync('./test/schema.alias.test.js').toString()),
|
|
29
|
+
...acquit.parse(fs.readFileSync('./test/model.middleware.test.js').toString())
|
|
29
30
|
];
|
|
30
31
|
|
|
31
32
|
function getVersion() {
|
package/lib/drivers/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ignore
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
var driver;
|
|
6
|
-
|
|
7
|
-
if (typeof window === 'undefined') {
|
|
8
|
-
driver = require('./node-mongodb-native');
|
|
9
|
-
if (global.MONGOOSE_DRIVER_PATH) {
|
|
10
|
-
driver = require(global.MONGOOSE_DRIVER_PATH);
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
driver = require('./browser');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/*!
|
|
17
|
-
* ignore
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
module.exports = driver;
|