mongoose 8.24.4 → 8.24.5
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.
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const get = require('../get');
|
|
4
4
|
const utils = require('../../utils');
|
|
5
|
+
|
|
6
|
+
const simpleCollation = Object.freeze({ locale: 'simple' });
|
|
7
|
+
|
|
5
8
|
/**
|
|
6
9
|
* Given a Mongoose index definition (key + options objects) and a MongoDB server
|
|
7
10
|
* index definition, determine if the two indexes are equal.
|
|
@@ -62,14 +65,13 @@ module.exports = function isIndexEqual(schemaIndexKeysObject, options, dbIndex)
|
|
|
62
65
|
continue;
|
|
63
66
|
}
|
|
64
67
|
if (key === 'collation') {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
if (get(schemaCollation, opt) !== get(dbCollation, opt)) {
|
|
68
|
+
// No collation is equivalent to { locale: 'simple' }. MongoDB server 9
|
|
69
|
+
// reports { locale: 'simple' } for indexes created with no collation,
|
|
70
|
+
// older versions omit it.
|
|
71
|
+
const schemaCollation = options.collation ?? simpleCollation;
|
|
72
|
+
const dbCollation = dbIndex.collation ?? simpleCollation;
|
|
73
|
+
for (const opt of Object.keys(schemaCollation)) {
|
|
74
|
+
if (schemaCollation[opt] !== dbCollation[opt]) {
|
|
73
75
|
return false;
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -209,6 +209,26 @@ const methods = {
|
|
|
209
209
|
return this.constructor.prototype.toObject.apply(this, arguments);
|
|
210
210
|
},
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Wraps [`MongooseArray#addToSet`](https://mongoosejs.com/docs/api/array.html#MongooseArray.prototype.addToSet())
|
|
214
|
+
* with proper change tracking.
|
|
215
|
+
*
|
|
216
|
+
* @param {...object} [args]
|
|
217
|
+
* @api public
|
|
218
|
+
* @method addToSet
|
|
219
|
+
* @memberOf MongooseDocumentArray
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
addToSet() {
|
|
223
|
+
// Arguments are cast before duplicates are skipped, so any value added
|
|
224
|
+
// after a skipped duplicate is cast with an index that is too high.
|
|
225
|
+
const ret = ArrayMethods.addToSet.apply(this, arguments);
|
|
226
|
+
|
|
227
|
+
_updateSubdocIndexes(this);
|
|
228
|
+
|
|
229
|
+
return ret;
|
|
230
|
+
},
|
|
231
|
+
|
|
212
232
|
/**
|
|
213
233
|
* Wraps [`Array#push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) with proper change tracking.
|
|
214
234
|
*
|