mongoose 6.4.1 → 6.4.4
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/.eslintrc.json +4 -2
- package/lib/aggregate.js +3 -2
- package/lib/cast/date.js +1 -1
- package/lib/cast/decimal128.js +1 -1
- package/lib/cast/objectid.js +1 -1
- package/lib/cast.js +1 -1
- package/lib/connection.js +9 -9
- package/lib/cursor/AggregationCursor.js +3 -2
- package/lib/cursor/QueryCursor.js +5 -4
- package/lib/document.js +48 -16
- package/lib/drivers/node-mongodb-native/index.js +1 -1
- package/lib/error/index.js +12 -12
- package/lib/error/messages.js +2 -2
- package/lib/error/parallelValidate.js +1 -1
- package/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +1 -1
- package/lib/helpers/aggregate/stringifyFunctionOperators.js +1 -1
- package/lib/helpers/arrayDepth.js +1 -1
- package/lib/helpers/cursor/eachAsync.js +1 -1
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +1 -1
- package/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +1 -1
- package/lib/helpers/discriminator/getConstructor.js +1 -1
- package/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
- package/lib/helpers/document/handleSpreadDoc.js +1 -1
- package/lib/helpers/each.js +1 -1
- package/lib/helpers/get.js +1 -1
- package/lib/helpers/getConstructorName.js +1 -1
- package/lib/helpers/getDefaultBulkwriteResult.js +1 -1
- package/lib/helpers/indexes/applySchemaCollation.js +1 -1
- package/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
- package/lib/helpers/indexes/isDefaultIdIndex.js +1 -1
- package/lib/helpers/indexes/isTextIndex.js +1 -1
- package/lib/helpers/isMongooseObject.js +1 -1
- package/lib/helpers/isObject.js +1 -1
- package/lib/helpers/isPromise.js +1 -1
- package/lib/helpers/model/applyHooks.js +1 -1
- package/lib/helpers/model/applyStaticHooks.js +1 -1
- package/lib/helpers/once.js +1 -1
- package/lib/helpers/path/flattenObjectWithDottedPaths.js +1 -1
- package/lib/helpers/path/parentPaths.js +1 -1
- package/lib/helpers/path/setDottedPath.js +1 -1
- package/lib/helpers/pluralize.js +1 -1
- package/lib/helpers/populate/SkipPopulateValue.js +1 -1
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +1 -1
- package/lib/helpers/populate/assignVals.js +1 -1
- package/lib/helpers/populate/createPopulateQueryFilter.js +1 -1
- package/lib/helpers/populate/getModelsMapForPopulate.js +1 -1
- package/lib/helpers/populate/leanPopulateMap.js +1 -1
- package/lib/helpers/populate/lookupLocalFields.js +1 -1
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/populate/modelNamesFromRefPath.js +1 -1
- package/lib/helpers/populate/removeDeselectedForeignField.js +1 -1
- package/lib/helpers/populate/validateRef.js +1 -1
- package/lib/helpers/printJestWarning.js +1 -1
- package/lib/helpers/processConnectionOptions.js +1 -1
- package/lib/helpers/projection/applyProjection.js +1 -1
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/helpers/projection/parseProjection.js +1 -1
- package/lib/helpers/query/applyGlobalOption.js +1 -1
- package/lib/helpers/query/applyQueryMiddleware.js +1 -1
- package/lib/helpers/query/cast$expr.js +1 -1
- package/lib/helpers/query/castFilterPath.js +1 -1
- package/lib/helpers/query/castUpdate.js +4 -4
- package/lib/helpers/query/sanitizeFilter.js +1 -1
- package/lib/helpers/query/sanitizeProjection.js +1 -1
- package/lib/helpers/query/trusted.js +1 -1
- package/lib/helpers/query/validOps.js +1 -1
- package/lib/helpers/query/wrapThunk.js +1 -1
- package/lib/helpers/schema/addAutoId.js +1 -1
- package/lib/helpers/schema/applyPlugins.js +1 -1
- package/lib/helpers/schema/cleanPositionalOperators.js +1 -1
- package/lib/helpers/schema/getKeysInSchemaOrder.js +1 -1
- package/lib/helpers/schema/getPath.js +1 -1
- package/lib/helpers/schema/handleIdOption.js +1 -1
- package/lib/helpers/schema/handleTimestampOption.js +1 -1
- package/lib/helpers/specialProperties.js +1 -1
- package/lib/helpers/symbols.js +1 -1
- package/lib/helpers/timers.js +1 -1
- package/lib/helpers/timestamps/setupTimestamps.js +1 -1
- package/lib/helpers/topology/allServersUnknown.js +1 -1
- package/lib/helpers/topology/isAtlas.js +1 -1
- package/lib/helpers/topology/isSSLError.js +1 -1
- package/lib/helpers/update/applyTimestampsToChildren.js +1 -1
- package/lib/helpers/update/castArrayFilters.js +1 -1
- package/lib/helpers/update/moveImmutableProperties.js +1 -1
- package/lib/helpers/update/removeUnusedArrayFilters.js +1 -1
- package/lib/helpers/update/updatedPathsByArrayFilter.js +1 -1
- package/lib/index.js +7 -4
- package/lib/model.js +22 -21
- package/lib/options/PopulateOptions.js +1 -1
- package/lib/options/SchemaArrayOptions.js +3 -3
- package/lib/options/SchemaBufferOptions.js +2 -2
- package/lib/options/SchemaDateOptions.js +3 -3
- package/lib/options/SchemaDocumentArrayOptions.js +3 -3
- package/lib/options/SchemaMapOptions.js +2 -2
- package/lib/options/SchemaNumberOptions.js +5 -5
- package/lib/options/SchemaObjectIdOptions.js +3 -3
- package/lib/options/SchemaStringOptions.js +8 -8
- package/lib/options/SchemaSubdocumentOptions.js +2 -2
- package/lib/options/SchemaTypeOptions.js +15 -15
- package/lib/options/VirtualOptions.js +12 -12
- package/lib/options/propertyOptions.js +1 -1
- package/lib/options/removeOptions.js +1 -1
- package/lib/options/saveOptions.js +1 -1
- package/lib/plugins/trackTransaction.js +1 -1
- package/lib/query.js +74 -71
- package/lib/schema/SubdocumentPath.js +10 -6
- package/lib/schema/array.js +3 -3
- package/lib/schema/boolean.js +5 -5
- package/lib/schema/buffer.js +2 -2
- package/lib/schema/date.js +2 -2
- package/lib/schema/decimal128.js +2 -2
- package/lib/schema/documentarray.js +12 -8
- package/lib/schema/mixed.js +2 -2
- package/lib/schema/number.js +2 -2
- package/lib/schema/objectid.js +2 -2
- package/lib/schema/string.js +2 -2
- package/lib/schema/symbols.js +1 -1
- package/lib/schema.js +72 -37
- package/lib/schematype.js +9 -10
- package/lib/types/DocumentArray/methods/index.js +2 -2
- package/lib/types/buffer.js +30 -28
- package/lib/types/decimal128.js +4 -4
- package/lib/types/map.js +70 -0
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +1 -1
- package/lib/virtualtype.js +5 -5
- package/package.json +13 -13
- package/types/collection.d.ts +1 -1
- package/types/document.d.ts +4 -4
- package/types/expressions.d.ts +27 -8
- package/types/index.d.ts +2 -1
- package/types/indexes.d.ts +2 -2
- package/types/inferschematype.d.ts +51 -33
- package/types/middlewares.d.ts +1 -1
- package/types/models.d.ts +8 -7
- package/types/mongooseoptions.d.ts +1 -1
- package/types/pipelinestage.d.ts +1 -1
- package/types/query.d.ts +6 -1
- package/types/schemaoptions.d.ts +1 -1
- package/types/utility.d.ts +7 -0
package/lib/helpers/once.js
CHANGED
package/lib/helpers/pluralize.js
CHANGED
|
@@ -14,4 +14,4 @@ if (typeof jest !== 'undefined' && process.nextTick.toString().indexOf('nextTick
|
|
|
14
14
|
'with Jest\'s mock timers enabled. Please make sure you read ' +
|
|
15
15
|
'Mongoose\'s docs on configuring Jest to test Node.js apps: ' +
|
|
16
16
|
'https://mongoosejs.com/docs/jest.html');
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -9,7 +9,7 @@ function processConnectionOptions(uri, options) {
|
|
|
9
9
|
? opts.readPreference
|
|
10
10
|
: getUriReadPreference(uri);
|
|
11
11
|
|
|
12
|
-
const resolvedOpts = (readPreference && readPreference !== 'primary')
|
|
12
|
+
const resolvedOpts = (readPreference && readPreference !== 'primary' && readPreference !== 'primaryPreferred')
|
|
13
13
|
? resolveOptsConflicts(readPreference, opts)
|
|
14
14
|
: opts;
|
|
15
15
|
|
|
@@ -155,12 +155,12 @@ function castPipelineOperator(op, val) {
|
|
|
155
155
|
* according to its schema.
|
|
156
156
|
*
|
|
157
157
|
* @param {Schema} schema
|
|
158
|
-
* @param {Object} obj
|
|
159
|
-
* @param {String} op
|
|
158
|
+
* @param {Object} obj part of a query
|
|
159
|
+
* @param {String} op the atomic operator ($pull, $set, etc)
|
|
160
160
|
* @param {Object} options
|
|
161
161
|
* @param {Boolean|String} [options.strict]
|
|
162
162
|
* @param {Query} context
|
|
163
|
-
* @param {String} pref
|
|
163
|
+
* @param {String} pref path prefix (internal only)
|
|
164
164
|
* @return {Bool} true if this path has keys to update
|
|
165
165
|
* @api private
|
|
166
166
|
*/
|
|
@@ -451,7 +451,7 @@ const overwriteOps = {
|
|
|
451
451
|
*
|
|
452
452
|
* @param {SchemaType} schema
|
|
453
453
|
* @param {Object} val
|
|
454
|
-
* @param {String} op
|
|
454
|
+
* @param {String} op the atomic operator ($pull, $set, etc)
|
|
455
455
|
* @param {String} $conditional
|
|
456
456
|
* @param {Query} context
|
|
457
457
|
* @api private
|
package/lib/helpers/symbols.js
CHANGED
|
@@ -17,4 +17,4 @@ exports.populateModelSymbol = Symbol('mongoose.PopulateOptions#Model');
|
|
|
17
17
|
exports.schemaTypeSymbol = Symbol('mongoose#schemaType');
|
|
18
18
|
exports.sessionNewDocuments = Symbol('mongoose:ClientSession#newDocuments');
|
|
19
19
|
exports.scopeSymbol = Symbol('mongoose#Document#scope');
|
|
20
|
-
exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
|
|
20
|
+
exports.validatorErrorSymbol = Symbol('mongoose:validatorError');
|
package/lib/helpers/timers.js
CHANGED
|
@@ -13,4 +13,4 @@ module.exports = function isSSLError(topologyDescription) {
|
|
|
13
13
|
const descriptions = Array.from(topologyDescription.servers.values());
|
|
14
14
|
return descriptions.length > 0 &&
|
|
15
15
|
descriptions.every(descr => descr.error && descr.error.message.indexOf(nonSSLMessage) !== -1);
|
|
16
|
-
};
|
|
16
|
+
};
|
package/lib/index.js
CHANGED
|
@@ -172,6 +172,7 @@ Mongoose.prototype.setDriver = function setDriver(driver) {
|
|
|
172
172
|
|
|
173
173
|
const Connection = driver.getConnection();
|
|
174
174
|
_mongoose.connections = [new Connection(_mongoose)];
|
|
175
|
+
_mongoose.connections[0].models = _mongoose.models;
|
|
175
176
|
|
|
176
177
|
return _mongoose;
|
|
177
178
|
};
|
|
@@ -761,6 +762,8 @@ Mongoose.prototype.Aggregate = Aggregate;
|
|
|
761
762
|
/**
|
|
762
763
|
* The Mongoose Collection constructor
|
|
763
764
|
*
|
|
765
|
+
* @memberOf Mongoose
|
|
766
|
+
* @instance
|
|
764
767
|
* @method Collection
|
|
765
768
|
* @api public
|
|
766
769
|
*/
|
|
@@ -799,7 +802,7 @@ Object.defineProperty(Mongoose.prototype, 'Connection', {
|
|
|
799
802
|
/**
|
|
800
803
|
* The Mongoose version
|
|
801
804
|
*
|
|
802
|
-
* #### Example
|
|
805
|
+
* #### Example:
|
|
803
806
|
*
|
|
804
807
|
* console.log(mongoose.version); // '5.x.x'
|
|
805
808
|
*
|
|
@@ -1044,7 +1047,7 @@ Mongoose.prototype.isObjectIdOrHexString = function(v) {
|
|
|
1044
1047
|
*
|
|
1045
1048
|
* @param {Object} options
|
|
1046
1049
|
* @param {Boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
|
|
1047
|
-
* @
|
|
1050
|
+
* @return {Promise} Returns a Promise, when the Promise resolves the value is a list of the dropped indexes.
|
|
1048
1051
|
*/
|
|
1049
1052
|
Mongoose.prototype.syncIndexes = function(options) {
|
|
1050
1053
|
const _mongoose = this instanceof Mongoose ? this : mongoose;
|
|
@@ -1223,7 +1226,7 @@ Mongoose.prototype._promiseOrCallback = function(callback, fn, ee) {
|
|
|
1223
1226
|
/**
|
|
1224
1227
|
* Use this function in `pre()` middleware to skip calling the wrapped function.
|
|
1225
1228
|
*
|
|
1226
|
-
* ####Example:
|
|
1229
|
+
* #### Example:
|
|
1227
1230
|
*
|
|
1228
1231
|
* schema.pre('save', function() {
|
|
1229
1232
|
* // Will skip executing `save()`, but will execute post hooks as if
|
|
@@ -1241,7 +1244,7 @@ Mongoose.prototype.skipMiddlewareFunction = Kareem.skipWrappedFunction;
|
|
|
1241
1244
|
/**
|
|
1242
1245
|
* Use this function in `post()` middleware to replace the result
|
|
1243
1246
|
*
|
|
1244
|
-
* ####Example:
|
|
1247
|
+
* #### Example:
|
|
1245
1248
|
*
|
|
1246
1249
|
* schema.post('find', function(res) {
|
|
1247
1250
|
* // Normally you have to modify `res` in place. But with
|
package/lib/model.js
CHANGED
|
@@ -212,7 +212,7 @@ Model.prototype.baseModelName;
|
|
|
212
212
|
* @api public
|
|
213
213
|
* @fires error whenever any query or model function errors
|
|
214
214
|
* @memberOf Model
|
|
215
|
-
* @static
|
|
215
|
+
* @static
|
|
216
216
|
*/
|
|
217
217
|
|
|
218
218
|
Model.events;
|
|
@@ -899,6 +899,7 @@ Model.prototype.$__version = function(where, delta) {
|
|
|
899
899
|
* })
|
|
900
900
|
*
|
|
901
901
|
* @see versionKeys https://mongoosejs.com/docs/guide.html#versionKey
|
|
902
|
+
* @memberOf Model
|
|
902
903
|
* @api public
|
|
903
904
|
*/
|
|
904
905
|
|
|
@@ -1453,7 +1454,7 @@ Model.createCollection = function createCollection(options, callback) {
|
|
|
1453
1454
|
* @param {Object} [options] options to pass to `ensureIndexes()`
|
|
1454
1455
|
* @param {Boolean} [options.background=null] if specified, overrides each index's `background` property
|
|
1455
1456
|
* @param {Function} [callback] optional callback
|
|
1456
|
-
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback.
|
|
1457
|
+
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback, when the Promise resolves the value is a list of the dropped indexes.
|
|
1457
1458
|
* @api public
|
|
1458
1459
|
*/
|
|
1459
1460
|
|
|
@@ -1821,7 +1822,7 @@ function _ensureIndexes(model, options, callback) {
|
|
|
1821
1822
|
* Schema the model uses.
|
|
1822
1823
|
*
|
|
1823
1824
|
* @property schema
|
|
1824
|
-
* @
|
|
1825
|
+
* @static
|
|
1825
1826
|
* @api public
|
|
1826
1827
|
* @memberOf Model
|
|
1827
1828
|
*/
|
|
@@ -2128,7 +2129,7 @@ Model.deleteMany = function deleteMany(conditions, options, callback) {
|
|
|
2128
2129
|
* await MyModel.find({ name: /john/i }, null, { skip: 10 }).exec();
|
|
2129
2130
|
*
|
|
2130
2131
|
* @param {Object|ObjectId} filter
|
|
2131
|
-
* @param {Object|String|
|
|
2132
|
+
* @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](https://mongoosejs.com/docs/api.html#query_Query-select)
|
|
2132
2133
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
2133
2134
|
* @param {Function} [callback]
|
|
2134
2135
|
* @return {Query}
|
|
@@ -2191,7 +2192,7 @@ Model.find = function find(conditions, projection, options, callback) {
|
|
|
2191
2192
|
* await Adventure.findById(id, 'name length').exec();
|
|
2192
2193
|
*
|
|
2193
2194
|
* @param {Any} id value of `_id` to query by
|
|
2194
|
-
* @param {Object|String|
|
|
2195
|
+
* @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2195
2196
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
2196
2197
|
* @param {Function} [callback]
|
|
2197
2198
|
* @return {Query}
|
|
@@ -2234,7 +2235,7 @@ Model.findById = function findById(id, projection, options, callback) {
|
|
|
2234
2235
|
* await Adventure.findOne({ country: 'Croatia' }, 'name length').exec();
|
|
2235
2236
|
*
|
|
2236
2237
|
* @param {Object} [conditions]
|
|
2237
|
-
* @param {Object|String|
|
|
2238
|
+
* @param {Object|String|String[]} [projection] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2238
2239
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
2239
2240
|
* @param {Function} [callback]
|
|
2240
2241
|
* @return {Query}
|
|
@@ -2383,7 +2384,7 @@ Model.count = function count(conditions, callback) {
|
|
|
2383
2384
|
*
|
|
2384
2385
|
* Passing a `callback` executes the query.
|
|
2385
2386
|
*
|
|
2386
|
-
* #### Example
|
|
2387
|
+
* #### Example:
|
|
2387
2388
|
*
|
|
2388
2389
|
* Link.distinct('url', { clicks: {$gt: 100}}, function (err, result) {
|
|
2389
2390
|
* if (err) return handleError(err);
|
|
@@ -2532,7 +2533,7 @@ Model.$where = function $where() {
|
|
|
2532
2533
|
* @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
2533
2534
|
* @param {Boolean} [options.overwrite=false] By default, if you don't include any [update operators](https://docs.mongodb.com/manual/reference/operator/update/) in `update`, Mongoose will wrap `update` in `$set` for you. This prevents you from accidentally overwriting the document. This option tells Mongoose to skip adding `$set`. An alternative to this would be using [Model.findOneAndReplace(conditions, update, options, callback)](https://mongoosejs.com/docs/api/model.html#model_Model.findOneAndReplace).
|
|
2534
2535
|
* @param {Boolean} [options.upsert=false] if true, and no documents found, insert a new document
|
|
2535
|
-
* @param {Object|String|
|
|
2536
|
+
* @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2536
2537
|
* @param {Function} [callback]
|
|
2537
2538
|
* @return {Query}
|
|
2538
2539
|
* @see Tutorial /docs/tutorials/findoneandupdate.html
|
|
@@ -2748,7 +2749,7 @@ Model.findByIdAndUpdate = function(id, update, options, callback) {
|
|
|
2748
2749
|
* @param {Object} conditions
|
|
2749
2750
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
2750
2751
|
* @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
2751
|
-
* @param {Object|String|
|
|
2752
|
+
* @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2752
2753
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
|
|
2753
2754
|
* @param {Function} [callback]
|
|
2754
2755
|
* @return {Query}
|
|
@@ -2854,7 +2855,7 @@ Model.findByIdAndDelete = function(id, options, callback) {
|
|
|
2854
2855
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
|
|
2855
2856
|
* @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
2856
2857
|
* @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
|
|
2857
|
-
* @param {Object|String|
|
|
2858
|
+
* @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2858
2859
|
* @param {Function} [callback]
|
|
2859
2860
|
* @return {Query}
|
|
2860
2861
|
* @api public
|
|
@@ -2941,7 +2942,7 @@ Model.findOneAndReplace = function(filter, replacement, options, callback) {
|
|
|
2941
2942
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
2942
2943
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
|
|
2943
2944
|
* @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
2944
|
-
* @param {Object|String|
|
|
2945
|
+
* @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
2945
2946
|
* @param {Function} [callback]
|
|
2946
2947
|
* @return {Query}
|
|
2947
2948
|
* @see mongodb https://www.mongodb.org/display/DOCS/findAndModify+Command
|
|
@@ -3007,7 +3008,7 @@ Model.findOneAndRemove = function(conditions, options, callback) {
|
|
|
3007
3008
|
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api.html#query_Query-setOptions)
|
|
3008
3009
|
* @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
|
|
3009
3010
|
* @param {ClientSession} [options.session=null] The session associated with this query. See [transactions docs](/docs/transactions.html).
|
|
3010
|
-
* @param {Object|String|
|
|
3011
|
+
* @param {Object|String|String[]} [options.projection=null] optional fields to return, see [`Query.prototype.select()`](#query_Query-select)
|
|
3011
3012
|
* @param {Function} [callback]
|
|
3012
3013
|
* @return {Query}
|
|
3013
3014
|
* @see Model.findOneAndRemove #model_Model.findOneAndRemove
|
|
@@ -3287,11 +3288,11 @@ Model.startSession = function() {
|
|
|
3287
3288
|
*
|
|
3288
3289
|
* @param {Array|Object|*} doc(s)
|
|
3289
3290
|
* @param {Object} [options] see the [mongodb driver options](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insertMany)
|
|
3290
|
-
* @param {Boolean} [options.ordered
|
|
3291
|
-
* @param {Boolean} [options.rawResult
|
|
3292
|
-
* @param {Boolean} [options.lean
|
|
3293
|
-
* @param {Number} [options.limit
|
|
3294
|
-
* @param {String|Object|Array} [options.populate
|
|
3291
|
+
* @param {Boolean} [options.ordered=true] if true, will fail fast on the first error encountered. If false, will insert all the documents it can and report errors later. An `insertMany()` with `ordered = false` is called an "unordered" `insertMany()`.
|
|
3292
|
+
* @param {Boolean} [options.rawResult=false] if false, the returned promise resolves to the documents that passed mongoose document validation. If `true`, will return the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#~insertWriteOpCallback) with a `mongoose` property that contains `validationErrors` if this is an unordered `insertMany`.
|
|
3293
|
+
* @param {Boolean} [options.lean=false] if `true`, skips hydrating and validating the documents. This option is useful if you need the extra performance, but Mongoose won't validate the documents before inserting.
|
|
3294
|
+
* @param {Number} [options.limit=null] this limits the number of documents being processed (validation/casting) by mongoose in parallel, this does **NOT** send the documents in batches to MongoDB. Use this option if you're processing a large number of documents and your app is running out of memory.
|
|
3295
|
+
* @param {String|Object|Array} [options.populate=null] populates the result documents. This option is a no-op if `rawResult` is set.
|
|
3295
3296
|
* @param {Function} [callback] callback
|
|
3296
3297
|
* @return {Promise} resolving to the raw result from the MongoDB driver if `options.rawResult` was `true`, or the documents that passed validation, otherwise
|
|
3297
3298
|
* @api public
|
|
@@ -3613,7 +3614,7 @@ Model.bulkWrite = function(ops, options, callback) {
|
|
|
3613
3614
|
*
|
|
3614
3615
|
* `bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)
|
|
3615
3616
|
*
|
|
3616
|
-
* @param {
|
|
3617
|
+
* @param {Array<Document>} documents
|
|
3617
3618
|
* @param {Object} [options] options passed to the underlying `bulkWrite()`
|
|
3618
3619
|
* @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html).
|
|
3619
3620
|
* @param {String|number} [options.w=1] The [write concern](https://docs.mongodb.com/manual/reference/write-concern/). See [`Query#w()`](/docs/api.html#query_Query-w) for more information.
|
|
@@ -3687,10 +3688,10 @@ function handleSuccessfulWrite(document, resolve, reject) {
|
|
|
3687
3688
|
|
|
3688
3689
|
/**
|
|
3689
3690
|
*
|
|
3690
|
-
* @param {
|
|
3691
|
+
* @param {Array<Document>} documents The array of documents to build write operations of
|
|
3691
3692
|
* @param {Object} options
|
|
3692
3693
|
* @param {Boolean} options.skipValidation defaults to `false`, when set to true, building the write operations will bypass validating the documents.
|
|
3693
|
-
* @
|
|
3694
|
+
* @return {Array<Promise>} Returns a array of all Promises the function executes to be awaited.
|
|
3694
3695
|
*/
|
|
3695
3696
|
Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, options) {
|
|
3696
3697
|
if (!Array.isArray(documents)) {
|
|
@@ -3764,7 +3765,7 @@ Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, op
|
|
|
3764
3765
|
* const mongooseCandy = Candy.hydrate({ _id: '54108337212ffb6d459f854c', type: 'jelly bean' });
|
|
3765
3766
|
*
|
|
3766
3767
|
* @param {Object} obj
|
|
3767
|
-
* @param {Object|String|
|
|
3768
|
+
* @param {Object|String|String[]} [projection] optional projection containing which fields should be selected for this document
|
|
3768
3769
|
* @return {Document} document instance
|
|
3769
3770
|
* @api public
|
|
3770
3771
|
*/
|
|
@@ -26,7 +26,7 @@ const opts = require('./propertyOptions');
|
|
|
26
26
|
* @api public
|
|
27
27
|
* @property enum
|
|
28
28
|
* @memberOf SchemaArrayOptions
|
|
29
|
-
* @type Array
|
|
29
|
+
* @type {Array}
|
|
30
30
|
* @instance
|
|
31
31
|
*/
|
|
32
32
|
|
|
@@ -46,7 +46,7 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts);
|
|
|
46
46
|
* @api public
|
|
47
47
|
* @property of
|
|
48
48
|
* @memberOf SchemaArrayOptions
|
|
49
|
-
* @type Function|String
|
|
49
|
+
* @type {Function|String}
|
|
50
50
|
* @instance
|
|
51
51
|
*/
|
|
52
52
|
|
|
@@ -56,4 +56,4 @@ Object.defineProperty(SchemaArrayOptions.prototype, 'of', opts);
|
|
|
56
56
|
* ignore
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
|
-
module.exports = SchemaArrayOptions;
|
|
59
|
+
module.exports = SchemaArrayOptions;
|