mongoose 6.2.9 → 6.2.10
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/CHANGELOG.md +6 -0
- package/dist/browser.umd.js +2 -2
- package/lib/aggregate.js +36 -36
- package/lib/browser.js +4 -4
- package/lib/connection.js +21 -21
- package/lib/cursor/AggregationCursor.js +2 -2
- package/lib/cursor/QueryCursor.js +3 -3
- package/lib/document.js +36 -36
- package/lib/error/index.js +2 -2
- package/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/lib/index.js +23 -23
- package/lib/model.js +83 -77
- package/lib/options/SchemaArrayOptions.js +2 -2
- package/lib/options/SchemaBufferOptions.js +1 -1
- package/lib/options/SchemaDateOptions.js +2 -2
- package/lib/options/SchemaDocumentArrayOptions.js +3 -3
- package/lib/options/SchemaMapOptions.js +2 -2
- package/lib/options/SchemaNumberOptions.js +3 -3
- package/lib/options/SchemaObjectIdOptions.js +2 -2
- package/lib/options/SchemaStringOptions.js +1 -1
- package/lib/options/SchemaSubdocumentOptions.js +2 -2
- package/lib/options/SchemaTypeOptions.js +3 -3
- package/lib/query.js +214 -223
- package/lib/schema/SubdocumentPath.js +2 -2
- package/lib/schema/array.js +2 -2
- package/lib/schema/boolean.js +4 -4
- package/lib/schema/buffer.js +3 -3
- package/lib/schema/date.js +7 -7
- package/lib/schema/decimal128.js +2 -2
- package/lib/schema/documentarray.js +3 -3
- package/lib/schema/mixed.js +2 -2
- package/lib/schema/number.js +6 -6
- package/lib/schema/objectid.js +4 -4
- package/lib/schema/string.js +14 -14
- package/lib/schema.js +28 -28
- package/lib/schematype.js +75 -67
- package/lib/types/ArraySubdocument.js +1 -1
- package/lib/types/DocumentArray/methods/index.js +2 -2
- package/lib/types/array/index.js +1 -1
- package/lib/types/array/methods/index.js +12 -12
- package/lib/types/buffer.js +1 -1
- package/lib/types/decimal128.js +1 -1
- package/lib/types/objectid.js +1 -1
- package/lib/types/subdocument.js +2 -2
- package/lib/virtualtype.js +3 -3
- package/package.json +10 -10
- package/types/index.d.ts +5 -3
package/lib/query.js
CHANGED
|
@@ -69,7 +69,7 @@ const queryOptionMethods = new Set([
|
|
|
69
69
|
* to instantiate a `Query` directly. Instead use Model functions like
|
|
70
70
|
* [`Model.find()`](/docs/api.html#find_find).
|
|
71
71
|
*
|
|
72
|
-
* ####Example:
|
|
72
|
+
* #### Example:
|
|
73
73
|
*
|
|
74
74
|
* const query = MyModel.find(); // `query` is an instance of `Query`
|
|
75
75
|
* query.setOptions({ lean : true });
|
|
@@ -154,7 +154,9 @@ Query.base = mquery.prototype;
|
|
|
154
154
|
/**
|
|
155
155
|
* Flag to opt out of using `$geoWithin`.
|
|
156
156
|
*
|
|
157
|
-
*
|
|
157
|
+
* ```javascript
|
|
158
|
+
* mongoose.Query.use$geoWithin = false;
|
|
159
|
+
* ```
|
|
158
160
|
*
|
|
159
161
|
* MongoDB 2.4 deprecated the use of `$within`, replacing it with `$geoWithin`. Mongoose uses `$geoWithin` by default (which is 100% backward compatible with `$within`). If you are running an older version of MongoDB, set this flag to `false` so your `within()` queries continue to work.
|
|
160
162
|
*
|
|
@@ -171,7 +173,7 @@ Query.use$geoWithin = mquery.use$geoWithin;
|
|
|
171
173
|
/**
|
|
172
174
|
* Converts this query to a customized, reusable query constructor with all arguments and options retained.
|
|
173
175
|
*
|
|
174
|
-
* ####Example
|
|
176
|
+
* #### Example
|
|
175
177
|
*
|
|
176
178
|
* // Create a query for adventure movies and read from the primary
|
|
177
179
|
* // node in the replica-set unless it is down, in which case we'll
|
|
@@ -253,7 +255,7 @@ Query.prototype.toConstructor = function toConstructor() {
|
|
|
253
255
|
/**
|
|
254
256
|
* Make a copy of this query so you can re-execute it.
|
|
255
257
|
*
|
|
256
|
-
* ####Example:
|
|
258
|
+
* #### Example:
|
|
257
259
|
* const q = Book.findOne({ title: 'Casino Royale' });
|
|
258
260
|
* await q.exec();
|
|
259
261
|
* await q.exec(); // Throws an error because you can't execute a query twice
|
|
@@ -301,7 +303,7 @@ Query.prototype.clone = function clone() {
|
|
|
301
303
|
/**
|
|
302
304
|
* Specifies a javascript function or expression to pass to MongoDBs query system.
|
|
303
305
|
*
|
|
304
|
-
* ####Example
|
|
306
|
+
* #### Example
|
|
305
307
|
*
|
|
306
308
|
* query.$where('this.comments.length === 10 || this.name.length === 5')
|
|
307
309
|
*
|
|
@@ -311,7 +313,7 @@ Query.prototype.clone = function clone() {
|
|
|
311
313
|
* return this.comments.length === 10 || this.name.length === 5;
|
|
312
314
|
* })
|
|
313
315
|
*
|
|
314
|
-
* ####
|
|
316
|
+
* #### Note:
|
|
315
317
|
*
|
|
316
318
|
* Only use `$where` when you have a condition that cannot be met using other MongoDB operators like `$lt`.
|
|
317
319
|
* **Be sure to read about all of [its caveats](https://docs.mongodb.org/manual/reference/operator/where/) before using.**
|
|
@@ -329,7 +331,7 @@ Query.prototype.clone = function clone() {
|
|
|
329
331
|
/**
|
|
330
332
|
* Specifies a `path` for use with chaining.
|
|
331
333
|
*
|
|
332
|
-
* ####Example
|
|
334
|
+
* #### Example
|
|
333
335
|
*
|
|
334
336
|
* // instead of writing:
|
|
335
337
|
* User.find({age: {$gte: 21, $lte: 65}}, callback);
|
|
@@ -359,13 +361,13 @@ Query.prototype.clone = function clone() {
|
|
|
359
361
|
/**
|
|
360
362
|
* Specifies a `$slice` projection for an array.
|
|
361
363
|
*
|
|
362
|
-
* ####Example
|
|
364
|
+
* #### Example
|
|
363
365
|
*
|
|
364
|
-
* query.slice('comments', 5)
|
|
365
|
-
* query.slice('comments', -5)
|
|
366
|
-
* query.slice('comments', [10, 5])
|
|
367
|
-
* query.where('comments').slice(5)
|
|
368
|
-
* query.where('comments').slice([-10, 5])
|
|
366
|
+
* query.slice('comments', 5);
|
|
367
|
+
* query.slice('comments', -5);
|
|
368
|
+
* query.slice('comments', [10, 5]);
|
|
369
|
+
* query.where('comments').slice(5);
|
|
370
|
+
* query.where('comments').slice([-10, 5]);
|
|
369
371
|
*
|
|
370
372
|
* @method slice
|
|
371
373
|
* @memberOf Query
|
|
@@ -437,7 +439,7 @@ Query.prototype._validateOp = function() {
|
|
|
437
439
|
/**
|
|
438
440
|
* Specifies the complementary comparison value for paths specified with `where()`
|
|
439
441
|
*
|
|
440
|
-
* ####Example
|
|
442
|
+
* #### Example
|
|
441
443
|
*
|
|
442
444
|
* User.where('age').equals(49);
|
|
443
445
|
*
|
|
@@ -456,9 +458,9 @@ Query.prototype._validateOp = function() {
|
|
|
456
458
|
/**
|
|
457
459
|
* Specifies arguments for an `$or` condition.
|
|
458
460
|
*
|
|
459
|
-
* ####Example
|
|
461
|
+
* #### Example
|
|
460
462
|
*
|
|
461
|
-
* query.or([{ color: 'red' }, { status: 'emergency' }])
|
|
463
|
+
* query.or([{ color: 'red' }, { status: 'emergency' }]);
|
|
462
464
|
*
|
|
463
465
|
* @see $or https://docs.mongodb.org/manual/reference/operator/or/
|
|
464
466
|
* @method or
|
|
@@ -472,9 +474,9 @@ Query.prototype._validateOp = function() {
|
|
|
472
474
|
/**
|
|
473
475
|
* Specifies arguments for a `$nor` condition.
|
|
474
476
|
*
|
|
475
|
-
* ####Example
|
|
477
|
+
* #### Example
|
|
476
478
|
*
|
|
477
|
-
* query.nor([{ color: 'green' }, { status: 'ok' }])
|
|
479
|
+
* query.nor([{ color: 'green' }, { status: 'ok' }]);
|
|
478
480
|
*
|
|
479
481
|
* @see $nor https://docs.mongodb.org/manual/reference/operator/nor/
|
|
480
482
|
* @method nor
|
|
@@ -488,7 +490,7 @@ Query.prototype._validateOp = function() {
|
|
|
488
490
|
/**
|
|
489
491
|
* Specifies arguments for a `$and` condition.
|
|
490
492
|
*
|
|
491
|
-
* ####Example
|
|
493
|
+
* #### Example
|
|
492
494
|
*
|
|
493
495
|
* query.and([{ color: 'green' }, { status: 'ok' }])
|
|
494
496
|
*
|
|
@@ -506,12 +508,12 @@ Query.prototype._validateOp = function() {
|
|
|
506
508
|
*
|
|
507
509
|
* When called with one argument, the most recent path passed to `where()` is used.
|
|
508
510
|
*
|
|
509
|
-
* ####Example
|
|
511
|
+
* #### Example
|
|
510
512
|
*
|
|
511
|
-
* Thing.find().where('age').gt(21)
|
|
513
|
+
* Thing.find().where('age').gt(21);
|
|
512
514
|
*
|
|
513
515
|
* // or
|
|
514
|
-
* Thing.find().gt('age', 21)
|
|
516
|
+
* Thing.find().gt('age', 21);
|
|
515
517
|
*
|
|
516
518
|
* @method gt
|
|
517
519
|
* @memberOf Query
|
|
@@ -611,7 +613,7 @@ Query.prototype._validateOp = function() {
|
|
|
611
613
|
*
|
|
612
614
|
* When called with one argument, the most recent path passed to `where()` is used.
|
|
613
615
|
*
|
|
614
|
-
* ####Example:
|
|
616
|
+
* #### Example:
|
|
615
617
|
*
|
|
616
618
|
* MyModel.find().where('pets').all(['dog', 'cat', 'ferret']);
|
|
617
619
|
* // Equivalent:
|
|
@@ -631,7 +633,7 @@ Query.prototype._validateOp = function() {
|
|
|
631
633
|
*
|
|
632
634
|
* When called with one argument, the most recent path passed to `where()` is used.
|
|
633
635
|
*
|
|
634
|
-
* ####Example
|
|
636
|
+
* #### Example
|
|
635
637
|
*
|
|
636
638
|
* const docs = await MyModel.where('tags').size(0).exec();
|
|
637
639
|
* assert(Array.isArray(docs));
|
|
@@ -678,7 +680,7 @@ Query.prototype._validateOp = function() {
|
|
|
678
680
|
* Specifies a `$mod` condition, filters documents for documents whose
|
|
679
681
|
* `path` property is a number that is equal to `remainder` modulo `divisor`.
|
|
680
682
|
*
|
|
681
|
-
* ####Example
|
|
683
|
+
* #### Example
|
|
682
684
|
*
|
|
683
685
|
* // All find products whose inventory is odd
|
|
684
686
|
* Product.find().mod('inventory', [2, 1]);
|
|
@@ -724,7 +726,7 @@ Query.prototype.mod = function() {
|
|
|
724
726
|
/**
|
|
725
727
|
* Specifies an `$exists` condition
|
|
726
728
|
*
|
|
727
|
-
* ####Example
|
|
729
|
+
* #### Example
|
|
728
730
|
*
|
|
729
731
|
* // { name: { $exists: true }}
|
|
730
732
|
* Thing.where('name').exists()
|
|
@@ -748,7 +750,7 @@ Query.prototype.mod = function() {
|
|
|
748
750
|
/**
|
|
749
751
|
* Specifies an `$elemMatch` condition
|
|
750
752
|
*
|
|
751
|
-
* ####Example
|
|
753
|
+
* #### Example
|
|
752
754
|
*
|
|
753
755
|
* query.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}})
|
|
754
756
|
*
|
|
@@ -777,7 +779,7 @@ Query.prototype.mod = function() {
|
|
|
777
779
|
/**
|
|
778
780
|
* Defines a `$within` or `$geoWithin` argument for geo-spatial queries.
|
|
779
781
|
*
|
|
780
|
-
* ####Example
|
|
782
|
+
* #### Example
|
|
781
783
|
*
|
|
782
784
|
* query.where(path).within().box()
|
|
783
785
|
* query.where(path).within().circle()
|
|
@@ -793,11 +795,11 @@ Query.prototype.mod = function() {
|
|
|
793
795
|
*
|
|
794
796
|
* **MUST** be used after `where()`.
|
|
795
797
|
*
|
|
796
|
-
* ####
|
|
798
|
+
* #### Note:
|
|
797
799
|
*
|
|
798
800
|
* As of Mongoose 3.7, `$geoWithin` is always used for queries. To change this behavior, see [Query.use$geoWithin](#query_Query-use%2524geoWithin).
|
|
799
801
|
*
|
|
800
|
-
* ####
|
|
802
|
+
* #### Note:
|
|
801
803
|
*
|
|
802
804
|
* In Mongoose 3.7, `within` changed from a getter to a function. If you need the old syntax, use [this](https://github.com/ebensing/mongoose-within).
|
|
803
805
|
*
|
|
@@ -816,11 +818,11 @@ Query.prototype.mod = function() {
|
|
|
816
818
|
/**
|
|
817
819
|
* Specifies the maximum number of documents the query will return.
|
|
818
820
|
*
|
|
819
|
-
* ####Example
|
|
821
|
+
* #### Example
|
|
820
822
|
*
|
|
821
|
-
* query.limit(20)
|
|
823
|
+
* query.limit(20);
|
|
822
824
|
*
|
|
823
|
-
* ####Note
|
|
825
|
+
* #### Note
|
|
824
826
|
*
|
|
825
827
|
* Cannot be used with `distinct()`
|
|
826
828
|
*
|
|
@@ -849,11 +851,11 @@ Query.prototype.limit = function limit(v) {
|
|
|
849
851
|
/**
|
|
850
852
|
* Specifies the number of documents to skip.
|
|
851
853
|
*
|
|
852
|
-
* ####Example
|
|
854
|
+
* #### Example
|
|
853
855
|
*
|
|
854
|
-
* query.skip(100).limit(20)
|
|
856
|
+
* query.skip(100).limit(20);
|
|
855
857
|
*
|
|
856
|
-
* ####Note
|
|
858
|
+
* #### Note
|
|
857
859
|
*
|
|
858
860
|
* Cannot be used with `distinct()`
|
|
859
861
|
*
|
|
@@ -883,11 +885,11 @@ Query.prototype.skip = function skip(v) {
|
|
|
883
885
|
/**
|
|
884
886
|
* Specifies the maxScan option.
|
|
885
887
|
*
|
|
886
|
-
* ####Example
|
|
888
|
+
* #### Example
|
|
887
889
|
*
|
|
888
|
-
* query.maxScan(100)
|
|
890
|
+
* query.maxScan(100);
|
|
889
891
|
*
|
|
890
|
-
* ####Note
|
|
892
|
+
* #### Note
|
|
891
893
|
*
|
|
892
894
|
* Cannot be used with `distinct()`
|
|
893
895
|
*
|
|
@@ -902,11 +904,11 @@ Query.prototype.skip = function skip(v) {
|
|
|
902
904
|
/**
|
|
903
905
|
* Specifies the batchSize option.
|
|
904
906
|
*
|
|
905
|
-
* ####Example
|
|
907
|
+
* #### Example
|
|
906
908
|
*
|
|
907
909
|
* query.batchSize(100)
|
|
908
910
|
*
|
|
909
|
-
* ####Note
|
|
911
|
+
* #### Note
|
|
910
912
|
*
|
|
911
913
|
* Cannot be used with `distinct()`
|
|
912
914
|
*
|
|
@@ -921,11 +923,11 @@ Query.prototype.skip = function skip(v) {
|
|
|
921
923
|
/**
|
|
922
924
|
* Specifies the `comment` option.
|
|
923
925
|
*
|
|
924
|
-
* ####Example
|
|
926
|
+
* #### Example
|
|
925
927
|
*
|
|
926
928
|
* query.comment('login query')
|
|
927
929
|
*
|
|
928
|
-
* ####Note
|
|
930
|
+
* #### Note
|
|
929
931
|
*
|
|
930
932
|
* Cannot be used with `distinct()`
|
|
931
933
|
*
|
|
@@ -940,13 +942,13 @@ Query.prototype.skip = function skip(v) {
|
|
|
940
942
|
/**
|
|
941
943
|
* Specifies this query as a `snapshot` query.
|
|
942
944
|
*
|
|
943
|
-
* ####Example
|
|
945
|
+
* #### Example
|
|
944
946
|
*
|
|
945
|
-
* query.snapshot() // true
|
|
946
|
-
* query.snapshot(true)
|
|
947
|
-
* query.snapshot(false)
|
|
947
|
+
* query.snapshot(); // true
|
|
948
|
+
* query.snapshot(true);
|
|
949
|
+
* query.snapshot(false);
|
|
948
950
|
*
|
|
949
|
-
* ####Note
|
|
951
|
+
* #### Note
|
|
950
952
|
*
|
|
951
953
|
* Cannot be used with `distinct()`
|
|
952
954
|
*
|
|
@@ -961,11 +963,11 @@ Query.prototype.skip = function skip(v) {
|
|
|
961
963
|
/**
|
|
962
964
|
* Sets query hints.
|
|
963
965
|
*
|
|
964
|
-
* ####Example
|
|
966
|
+
* #### Example
|
|
965
967
|
*
|
|
966
|
-
* query.hint({ indexA: 1, indexB: -1})
|
|
968
|
+
* query.hint({ indexA: 1, indexB: -1 });
|
|
967
969
|
*
|
|
968
|
-
* ####Note
|
|
970
|
+
* #### Note
|
|
969
971
|
*
|
|
970
972
|
* Cannot be used with `distinct()`
|
|
971
973
|
*
|
|
@@ -985,7 +987,7 @@ Query.prototype.skip = function skip(v) {
|
|
|
985
987
|
* Unlike `projection()`, the `select()` function modifies the current
|
|
986
988
|
* projection in place. This function overwrites the existing projection.
|
|
987
989
|
*
|
|
988
|
-
* ####Example:
|
|
990
|
+
* #### Example:
|
|
989
991
|
*
|
|
990
992
|
* const q = Model.find();
|
|
991
993
|
* q.projection(); // null
|
|
@@ -1028,7 +1030,7 @@ Query.prototype.projection = function(arg) {
|
|
|
1028
1030
|
* either list the fields to include (which excludes all others), or list the fields
|
|
1029
1031
|
* to exclude (which implies all other fields are included). The [`_id` field is the only exception because MongoDB includes it by default](https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/#suppress-id-field).
|
|
1030
1032
|
*
|
|
1031
|
-
* ####Example
|
|
1033
|
+
* #### Example
|
|
1032
1034
|
*
|
|
1033
1035
|
* // include a and b, exclude other fields
|
|
1034
1036
|
* query.select('a b');
|
|
@@ -1139,49 +1141,30 @@ Query.prototype.select = function select() {
|
|
|
1139
1141
|
throw new TypeError('Invalid select() argument. Must be string or object.');
|
|
1140
1142
|
};
|
|
1141
1143
|
|
|
1142
|
-
/**
|
|
1143
|
-
* _DEPRECATED_ Sets the slaveOk option.
|
|
1144
|
-
*
|
|
1145
|
-
* **Deprecated** in MongoDB 2.2 in favor of [read preferences](#query_Query-read).
|
|
1146
|
-
*
|
|
1147
|
-
* ####Example:
|
|
1148
|
-
*
|
|
1149
|
-
* query.slaveOk() // true
|
|
1150
|
-
* query.slaveOk(true)
|
|
1151
|
-
* query.slaveOk(false)
|
|
1152
|
-
*
|
|
1153
|
-
* @method slaveOk
|
|
1154
|
-
* @memberOf Query
|
|
1155
|
-
* @instance
|
|
1156
|
-
* @deprecated use read() preferences instead if on mongodb >= 2.2
|
|
1157
|
-
* @param {Boolean} v defaults to true
|
|
1158
|
-
* @see mongodb https://docs.mongodb.org/manual/applications/replication/#read-preference
|
|
1159
|
-
* @see slaveOk https://docs.mongodb.org/manual/reference/method/rs.slaveOk/
|
|
1160
|
-
* @see read() #query_Query-read
|
|
1161
|
-
* @return {Query} this
|
|
1162
|
-
* @api public
|
|
1163
|
-
*/
|
|
1164
|
-
|
|
1165
1144
|
/**
|
|
1166
1145
|
* Determines the MongoDB nodes from which to read.
|
|
1167
1146
|
*
|
|
1168
|
-
* ####Preferences:
|
|
1147
|
+
* #### Preferences:
|
|
1169
1148
|
*
|
|
1170
|
-
*
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1149
|
+
* ```
|
|
1150
|
+
* primary - (default) Read from primary only. Operations will produce an error if primary is unavailable. Cannot be combined with tags.
|
|
1151
|
+
* secondary Read from secondary if available, otherwise error.
|
|
1152
|
+
* primaryPreferred Read from primary if available, otherwise a secondary.
|
|
1153
|
+
* secondaryPreferred Read from a secondary if available, otherwise read from the primary.
|
|
1154
|
+
* nearest All operations read from among the nearest candidates, but unlike other modes, this option will include both the primary and all secondaries in the random selection.
|
|
1155
|
+
* ```
|
|
1175
1156
|
*
|
|
1176
1157
|
* Aliases
|
|
1177
1158
|
*
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1159
|
+
* ```
|
|
1160
|
+
* p primary
|
|
1161
|
+
* pp primaryPreferred
|
|
1162
|
+
* s secondary
|
|
1163
|
+
* sp secondaryPreferred
|
|
1164
|
+
* n nearest
|
|
1165
|
+
* ```
|
|
1183
1166
|
*
|
|
1184
|
-
* ####Example:
|
|
1167
|
+
* #### Example:
|
|
1185
1168
|
*
|
|
1186
1169
|
* new Query().read('primary')
|
|
1187
1170
|
* new Query().read('p') // same as primary
|
|
@@ -1260,7 +1243,7 @@ Query.prototype.toString = function toString() {
|
|
|
1260
1243
|
*
|
|
1261
1244
|
* Calling `session(null)` removes the session from this query.
|
|
1262
1245
|
*
|
|
1263
|
-
* ####Example:
|
|
1246
|
+
* #### Example:
|
|
1264
1247
|
*
|
|
1265
1248
|
* const s = await mongoose.startSession();
|
|
1266
1249
|
* await mongoose.model('Person').findOne({ name: 'Axl Rose' }).session(s);
|
|
@@ -1304,7 +1287,7 @@ Query.prototype.session = function session(v) {
|
|
|
1304
1287
|
*
|
|
1305
1288
|
* Defaults to the schema's [`writeConcern` option](/docs/guide.html#writeConcern)
|
|
1306
1289
|
*
|
|
1307
|
-
* ####Example:
|
|
1290
|
+
* #### Example:
|
|
1308
1291
|
*
|
|
1309
1292
|
* // The 'majority' option means the `deleteOne()` promise won't resolve
|
|
1310
1293
|
* // until the `deleteOne()` has propagated to the majority of the replica set
|
|
@@ -1347,7 +1330,7 @@ Query.prototype.writeConcern = function writeConcern(val) {
|
|
|
1347
1330
|
*
|
|
1348
1331
|
* Defaults to the schema's [`writeConcern.w` option](/docs/guide.html#writeConcern)
|
|
1349
1332
|
*
|
|
1350
|
-
* ####Example:
|
|
1333
|
+
* #### Example:
|
|
1351
1334
|
*
|
|
1352
1335
|
* // The 'majority' option means the `deleteOne()` promise won't resolve
|
|
1353
1336
|
* // until the `deleteOne()` has propagated to the majority of the replica set
|
|
@@ -1393,7 +1376,7 @@ Query.prototype.w = function w(val) {
|
|
|
1393
1376
|
*
|
|
1394
1377
|
* Defaults to the schema's [`writeConcern.j` option](/docs/guide.html#writeConcern)
|
|
1395
1378
|
*
|
|
1396
|
-
* ####Example:
|
|
1379
|
+
* #### Example:
|
|
1397
1380
|
*
|
|
1398
1381
|
* await mongoose.model('Person').deleteOne({ name: 'Ned Stark' }).j(true);
|
|
1399
1382
|
*
|
|
@@ -1437,7 +1420,7 @@ Query.prototype.j = function j(val) {
|
|
|
1437
1420
|
*
|
|
1438
1421
|
* Defaults to the schema's [`writeConcern.wtimeout` option](/docs/guide.html#writeConcern)
|
|
1439
1422
|
*
|
|
1440
|
-
* ####Example:
|
|
1423
|
+
* #### Example:
|
|
1441
1424
|
*
|
|
1442
1425
|
* // The `deleteOne()` promise won't resolve until this `deleteOne()` has
|
|
1443
1426
|
* // propagated to at least `w = 2` members of the replica set. If it takes
|
|
@@ -1471,7 +1454,7 @@ Query.prototype.wtimeout = function wtimeout(ms) {
|
|
|
1471
1454
|
/**
|
|
1472
1455
|
* Sets the readConcern option for the query.
|
|
1473
1456
|
*
|
|
1474
|
-
* ####Example:
|
|
1457
|
+
* #### Example:
|
|
1475
1458
|
*
|
|
1476
1459
|
* new Query().readConcern('local')
|
|
1477
1460
|
* new Query().readConcern('l') // same as local
|
|
@@ -1489,21 +1472,25 @@ Query.prototype.wtimeout = function wtimeout(ms) {
|
|
|
1489
1472
|
* new Query().readConcern('s') // same as snapshot
|
|
1490
1473
|
*
|
|
1491
1474
|
*
|
|
1492
|
-
* ####Read Concern Level:
|
|
1475
|
+
* #### Read Concern Level:
|
|
1493
1476
|
*
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1477
|
+
* ```
|
|
1478
|
+
* local MongoDB 3.2+ The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back).
|
|
1479
|
+
* available MongoDB 3.6+ The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back).
|
|
1480
|
+
* majority MongoDB 3.2+ The query returns the data that has been acknowledged by a majority of the replica set members. The documents returned by the read operation are durable, even in the event of failure.
|
|
1481
|
+
* linearizable MongoDB 3.4+ The query returns data that reflects all successful majority-acknowledged writes that completed prior to the start of the read operation. The query may wait for concurrently executing writes to propagate to a majority of replica set members before returning results.
|
|
1482
|
+
* snapshot MongoDB 4.0+ Only available for operations within multi-document transactions. Upon transaction commit with write concern "majority", the transaction operations are guaranteed to have read from a snapshot of majority-committed data.
|
|
1483
|
+
* ```
|
|
1499
1484
|
*
|
|
1500
1485
|
* Aliases
|
|
1501
1486
|
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1505
|
-
*
|
|
1506
|
-
*
|
|
1487
|
+
* ```
|
|
1488
|
+
* l local
|
|
1489
|
+
* a available
|
|
1490
|
+
* m majority
|
|
1491
|
+
* lz linearizable
|
|
1492
|
+
* s snapshot
|
|
1493
|
+
* ```
|
|
1507
1494
|
*
|
|
1508
1495
|
* Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/).
|
|
1509
1496
|
*
|
|
@@ -1518,11 +1505,11 @@ Query.prototype.wtimeout = function wtimeout(ms) {
|
|
|
1518
1505
|
/**
|
|
1519
1506
|
* Gets query options.
|
|
1520
1507
|
*
|
|
1521
|
-
* ####Example:
|
|
1508
|
+
* #### Example:
|
|
1522
1509
|
*
|
|
1523
1510
|
* const query = new Query();
|
|
1524
1511
|
* query.limit(10);
|
|
1525
|
-
* query.setOptions({ maxTimeMS: 1000 })
|
|
1512
|
+
* query.setOptions({ maxTimeMS: 1000 });
|
|
1526
1513
|
* query.getOptions(); // { limit: 10, maxTimeMS: 1000 }
|
|
1527
1514
|
*
|
|
1528
1515
|
* @return {Object} the options
|
|
@@ -1536,7 +1523,7 @@ Query.prototype.getOptions = function() {
|
|
|
1536
1523
|
/**
|
|
1537
1524
|
* Sets query options. Some options only make sense for certain operations.
|
|
1538
1525
|
*
|
|
1539
|
-
* ####Options:
|
|
1526
|
+
* #### Options:
|
|
1540
1527
|
*
|
|
1541
1528
|
* The following options are only for `find()`:
|
|
1542
1529
|
*
|
|
@@ -1678,7 +1665,7 @@ Query.prototype.setOptions = function(options, overwrite) {
|
|
|
1678
1665
|
*
|
|
1679
1666
|
* Calling `query.explain(v)` is equivalent to `query.setOptions({ explain: v })`
|
|
1680
1667
|
*
|
|
1681
|
-
* ####Example:
|
|
1668
|
+
* #### Example:
|
|
1682
1669
|
*
|
|
1683
1670
|
* const query = new Query();
|
|
1684
1671
|
* const res = await query.find({ a: 1 }).explain('queryPlanner');
|
|
@@ -1710,7 +1697,7 @@ Query.prototype.explain = function(verbose) {
|
|
|
1710
1697
|
*
|
|
1711
1698
|
* Calling `query.allowDiskUse(v)` is equivalent to `query.setOptions({ allowDiskUse: v })`
|
|
1712
1699
|
*
|
|
1713
|
-
* ####Example:
|
|
1700
|
+
* #### Example:
|
|
1714
1701
|
*
|
|
1715
1702
|
* await query.find().sort({ name: 1 }).allowDiskUse(true);
|
|
1716
1703
|
* // Equivalent:
|
|
@@ -1739,7 +1726,7 @@ Query.prototype.allowDiskUse = function(v) {
|
|
|
1739
1726
|
*
|
|
1740
1727
|
* Calling `query.maxTimeMS(v)` is equivalent to `query.setOptions({ maxTimeMS: v })`
|
|
1741
1728
|
*
|
|
1742
|
-
* ####Example:
|
|
1729
|
+
* #### Example:
|
|
1743
1730
|
*
|
|
1744
1731
|
* const query = new Query();
|
|
1745
1732
|
* // Throws an error 'operation exceeded time limit' as long as there's
|
|
@@ -1759,7 +1746,7 @@ Query.prototype.maxTimeMS = function(ms) {
|
|
|
1759
1746
|
/**
|
|
1760
1747
|
* Returns the current query filter (also known as conditions) as a [POJO](https://masteringjs.io/tutorials/fundamentals/pojo).
|
|
1761
1748
|
*
|
|
1762
|
-
* ####Example:
|
|
1749
|
+
* #### Example:
|
|
1763
1750
|
*
|
|
1764
1751
|
* const query = new Query();
|
|
1765
1752
|
* query.find({ a: 1 }).where('b').gt(2);
|
|
@@ -1779,7 +1766,7 @@ Query.prototype.getFilter = function() {
|
|
|
1779
1766
|
* You should use `getFilter()` instead of `getQuery()` where possible. `getQuery()`
|
|
1780
1767
|
* will likely be deprecated in a future release.
|
|
1781
1768
|
*
|
|
1782
|
-
* ####Example:
|
|
1769
|
+
* #### Example:
|
|
1783
1770
|
*
|
|
1784
1771
|
* const query = new Query();
|
|
1785
1772
|
* query.find({ a: 1 }).where('b').gt(2);
|
|
@@ -1796,7 +1783,7 @@ Query.prototype.getQuery = function() {
|
|
|
1796
1783
|
/**
|
|
1797
1784
|
* Sets the query conditions to the provided JSON object.
|
|
1798
1785
|
*
|
|
1799
|
-
* ####Example:
|
|
1786
|
+
* #### Example:
|
|
1800
1787
|
*
|
|
1801
1788
|
* const query = new Query();
|
|
1802
1789
|
* query.find({ a: 1 })
|
|
@@ -1815,7 +1802,7 @@ Query.prototype.setQuery = function(val) {
|
|
|
1815
1802
|
/**
|
|
1816
1803
|
* Returns the current update operations as a JSON object.
|
|
1817
1804
|
*
|
|
1818
|
-
* ####Example:
|
|
1805
|
+
* #### Example:
|
|
1819
1806
|
*
|
|
1820
1807
|
* const query = new Query();
|
|
1821
1808
|
* query.update({}, { $set: { a: 5 } });
|
|
@@ -1832,7 +1819,7 @@ Query.prototype.getUpdate = function() {
|
|
|
1832
1819
|
/**
|
|
1833
1820
|
* Sets the current update operation to new value.
|
|
1834
1821
|
*
|
|
1835
|
-
* ####Example:
|
|
1822
|
+
* #### Example:
|
|
1836
1823
|
*
|
|
1837
1824
|
* const query = new Query();
|
|
1838
1825
|
* query.update({}, { $set: { a: 5 } });
|
|
@@ -1985,7 +1972,7 @@ Query.prototype._optionsForExec = function(model) {
|
|
|
1985
1972
|
* javascript objects, not [Mongoose Documents](/api/document.html). They have no
|
|
1986
1973
|
* `save` method, getters/setters, virtuals, or other Mongoose features.
|
|
1987
1974
|
*
|
|
1988
|
-
* ####Example:
|
|
1975
|
+
* #### Example:
|
|
1989
1976
|
*
|
|
1990
1977
|
* new Query().lean() // true
|
|
1991
1978
|
* new Query().lean(true)
|
|
@@ -2020,7 +2007,7 @@ Query.prototype.lean = function(v) {
|
|
|
2020
2007
|
* This is useful for query middleware so you can add an update regardless
|
|
2021
2008
|
* of whether you use `updateOne()`, `updateMany()`, `findOneAndUpdate()`, etc.
|
|
2022
2009
|
*
|
|
2023
|
-
* ####Example:
|
|
2010
|
+
* #### Example:
|
|
2024
2011
|
*
|
|
2025
2012
|
* // Updates `{ $set: { updatedAt: new Date() } }`
|
|
2026
2013
|
* new Query().updateOne({}, {}).set('updatedAt', new Date());
|
|
@@ -2052,7 +2039,7 @@ Query.prototype.set = function(path, val) {
|
|
|
2052
2039
|
* Useful for writing getters/setters that can work with both update operations
|
|
2053
2040
|
* and `save()`.
|
|
2054
2041
|
*
|
|
2055
|
-
* ####Example:
|
|
2042
|
+
* #### Example:
|
|
2056
2043
|
*
|
|
2057
2044
|
* const query = Model.updateOne({}, { $set: { name: 'Jean-Luc Picard' } });
|
|
2058
2045
|
* query.get('name'); // 'Jean-Luc Picard'
|
|
@@ -2086,7 +2073,7 @@ Query.prototype.get = function get(path) {
|
|
|
2086
2073
|
* Gets/sets the error flag on this query. If this flag is not null or
|
|
2087
2074
|
* undefined, the `exec()` promise will reject without executing.
|
|
2088
2075
|
*
|
|
2089
|
-
* ####Example:
|
|
2076
|
+
* #### Example:
|
|
2090
2077
|
*
|
|
2091
2078
|
* Query().error(); // Get current error value
|
|
2092
2079
|
* Query().error(null); // Unset the current error
|
|
@@ -2100,7 +2087,7 @@ Query.prototype.get = function get(path) {
|
|
|
2100
2087
|
* Note that query casting runs **after** hooks, so cast errors will override
|
|
2101
2088
|
* custom errors.
|
|
2102
2089
|
*
|
|
2103
|
-
* ####Example:
|
|
2090
|
+
* #### Example:
|
|
2104
2091
|
* const TestSchema = new Schema({ num: Number });
|
|
2105
2092
|
* const TestModel = db.model('Test', TestSchema);
|
|
2106
2093
|
* TestModel.find({ num: 'not a number' }).error(new Error('woops')).exec(function(error) {
|
|
@@ -2287,7 +2274,7 @@ Query.prototype._find = wrapThunk(function(callback) {
|
|
|
2287
2274
|
* If there are too many documents in the result to fit in memory, use
|
|
2288
2275
|
* [`Query.prototype.cursor()`](api.html#query_Query-cursor)
|
|
2289
2276
|
*
|
|
2290
|
-
* ####Example
|
|
2277
|
+
* #### Example
|
|
2291
2278
|
*
|
|
2292
2279
|
* // Using async/await
|
|
2293
2280
|
* const arr = await Movie.find({ year: { $gte: 1980, $lte: 1989 } });
|
|
@@ -2493,7 +2480,7 @@ Query.prototype._findOne = wrapThunk(function(callback) {
|
|
|
2493
2480
|
*
|
|
2494
2481
|
* - `findOne()`
|
|
2495
2482
|
*
|
|
2496
|
-
* ####Example
|
|
2483
|
+
* #### Example
|
|
2497
2484
|
*
|
|
2498
2485
|
* const query = Kitten.where({ color: 'white' });
|
|
2499
2486
|
* query.findOne(function (err, kitten) {
|
|
@@ -2644,7 +2631,7 @@ Query.prototype._estimatedDocumentCount = wrapThunk(function(callback) {
|
|
|
2644
2631
|
*
|
|
2645
2632
|
* - `count()`
|
|
2646
2633
|
*
|
|
2647
|
-
* ####Example:
|
|
2634
|
+
* #### Example:
|
|
2648
2635
|
*
|
|
2649
2636
|
* const countQuery = model.where({ 'color': 'black' }).count();
|
|
2650
2637
|
*
|
|
@@ -2701,7 +2688,7 @@ Query.prototype.count = function(filter, callback) {
|
|
|
2701
2688
|
*
|
|
2702
2689
|
* - `estimatedDocumentCount()`
|
|
2703
2690
|
*
|
|
2704
|
-
* ####Example:
|
|
2691
|
+
* #### Example:
|
|
2705
2692
|
*
|
|
2706
2693
|
* await Model.find().estimatedDocumentCount();
|
|
2707
2694
|
*
|
|
@@ -2747,7 +2734,7 @@ Query.prototype.estimatedDocumentCount = function(options, callback) {
|
|
|
2747
2734
|
*
|
|
2748
2735
|
* - `countDocuments()`
|
|
2749
2736
|
*
|
|
2750
|
-
* ####Example:
|
|
2737
|
+
* #### Example:
|
|
2751
2738
|
*
|
|
2752
2739
|
* const countQuery = model.where({ 'color': 'black' }).countDocuments();
|
|
2753
2740
|
*
|
|
@@ -2841,7 +2828,7 @@ Query.prototype.__distinct = wrapThunk(function __distinct(callback) {
|
|
|
2841
2828
|
*
|
|
2842
2829
|
* This function does not trigger any middleware.
|
|
2843
2830
|
*
|
|
2844
|
-
* ####Example
|
|
2831
|
+
* #### Example
|
|
2845
2832
|
*
|
|
2846
2833
|
* distinct(field, conditions, callback)
|
|
2847
2834
|
* distinct(field, conditions)
|
|
@@ -2902,7 +2889,7 @@ Query.prototype.distinct = function(field, conditions, callback) {
|
|
|
2902
2889
|
* sort order of each path is ascending unless the path name is prefixed with `-`
|
|
2903
2890
|
* which will be treated as descending.
|
|
2904
2891
|
*
|
|
2905
|
-
* ####Example
|
|
2892
|
+
* #### Example
|
|
2906
2893
|
*
|
|
2907
2894
|
* // sort by "field" ascending and "test" descending
|
|
2908
2895
|
* query.sort({ field: 'asc', test: -1 });
|
|
@@ -2910,7 +2897,7 @@ Query.prototype.distinct = function(field, conditions, callback) {
|
|
|
2910
2897
|
* // equivalent
|
|
2911
2898
|
* query.sort('field -test');
|
|
2912
2899
|
*
|
|
2913
|
-
* ####Note
|
|
2900
|
+
* #### Note
|
|
2914
2901
|
*
|
|
2915
2902
|
* Cannot be used with `distinct()`
|
|
2916
2903
|
*
|
|
@@ -2935,7 +2922,7 @@ Query.prototype.sort = function(arg) {
|
|
|
2935
2922
|
*
|
|
2936
2923
|
* This function does not trigger any middleware
|
|
2937
2924
|
*
|
|
2938
|
-
* ####Example
|
|
2925
|
+
* #### Example
|
|
2939
2926
|
*
|
|
2940
2927
|
* Character.remove({ name: /Stark/ }, callback);
|
|
2941
2928
|
*
|
|
@@ -2947,13 +2934,13 @@ Query.prototype.sort = function(arg) {
|
|
|
2947
2934
|
* - `deletedCount`: the number of documents deleted
|
|
2948
2935
|
* - `n`: the number of documents deleted. Equal to `deletedCount`.
|
|
2949
2936
|
*
|
|
2950
|
-
* ####Example
|
|
2937
|
+
* #### Example
|
|
2951
2938
|
*
|
|
2952
2939
|
* const res = await Character.remove({ name: /Stark/ });
|
|
2953
2940
|
* // Number of docs deleted
|
|
2954
2941
|
* res.deletedCount;
|
|
2955
2942
|
*
|
|
2956
|
-
* ####Note
|
|
2943
|
+
* #### Note
|
|
2957
2944
|
*
|
|
2958
2945
|
* Calling `remove()` creates a [Mongoose query](./queries.html), and a query
|
|
2959
2946
|
* does not execute until you either pass a callback, call [`Query#then()`](#query_Query-then),
|
|
@@ -3027,7 +3014,7 @@ Query.prototype._remove = wrapThunk(function(callback) {
|
|
|
3027
3014
|
*
|
|
3028
3015
|
* This function triggers `deleteOne` middleware.
|
|
3029
3016
|
*
|
|
3030
|
-
* ####Example
|
|
3017
|
+
* #### Example
|
|
3031
3018
|
*
|
|
3032
3019
|
* await Character.deleteOne({ name: 'Eddard Stark' });
|
|
3033
3020
|
*
|
|
@@ -3042,7 +3029,7 @@ Query.prototype._remove = wrapThunk(function(callback) {
|
|
|
3042
3029
|
* - `deletedCount`: the number of documents deleted
|
|
3043
3030
|
* - `n`: the number of documents deleted. Equal to `deletedCount`.
|
|
3044
3031
|
*
|
|
3045
|
-
* ####Example
|
|
3032
|
+
* #### Example
|
|
3046
3033
|
*
|
|
3047
3034
|
* const res = await Character.deleteOne({ name: 'Eddard Stark' });
|
|
3048
3035
|
* // `1` if MongoDB deleted a doc, `0` if no docs matched the filter `{ name: ... }`
|
|
@@ -3113,7 +3100,7 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
|
|
|
3113
3100
|
*
|
|
3114
3101
|
* This function triggers `deleteMany` middleware.
|
|
3115
3102
|
*
|
|
3116
|
-
* ####Example
|
|
3103
|
+
* #### Example
|
|
3117
3104
|
*
|
|
3118
3105
|
* await Character.deleteMany({ name: /Stark/, age: { $gte: 18 } });
|
|
3119
3106
|
*
|
|
@@ -3128,7 +3115,7 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
|
|
|
3128
3115
|
* - `deletedCount`: the number of documents deleted
|
|
3129
3116
|
* - `n`: the number of documents deleted. Equal to `deletedCount`.
|
|
3130
3117
|
*
|
|
3131
|
-
* ####Example
|
|
3118
|
+
* #### Example
|
|
3132
3119
|
*
|
|
3133
3120
|
* const res = await Character.deleteMany({ name: /Stark/, age: { $gte: 18 } });
|
|
3134
3121
|
* // `0` if no docs matched the filter, number of docs deleted otherwise
|
|
@@ -3263,7 +3250,7 @@ function prepareDiscriminatorCriteria(query) {
|
|
|
3263
3250
|
*
|
|
3264
3251
|
* - `findOneAndUpdate()`
|
|
3265
3252
|
*
|
|
3266
|
-
* ####Available options
|
|
3253
|
+
* #### Available options
|
|
3267
3254
|
*
|
|
3268
3255
|
* - `new`: bool - if true, return the modified document rather than the original. defaults to false (changed in 4.0)
|
|
3269
3256
|
* - `upsert`: bool - creates the object if it doesn't exist. defaults to false.
|
|
@@ -3274,13 +3261,13 @@ function prepareDiscriminatorCriteria(query) {
|
|
|
3274
3261
|
* - `setDefaultsOnInsert`: `true` by default. If `setDefaultsOnInsert` and `upsert` are true, mongoose will apply the [defaults](https://mongoosejs.com/docs/defaults.html) specified in the model's schema if a new document is created.
|
|
3275
3262
|
* - `rawResult`: if true, returns the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
|
|
3276
3263
|
*
|
|
3277
|
-
* ####Callback Signature
|
|
3264
|
+
* #### Callback Signature
|
|
3278
3265
|
* function(error, doc) {
|
|
3279
3266
|
* // error: any errors that occurred
|
|
3280
3267
|
* // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
|
|
3281
3268
|
* }
|
|
3282
3269
|
*
|
|
3283
|
-
* ####Examples
|
|
3270
|
+
* #### Examples
|
|
3284
3271
|
*
|
|
3285
3272
|
* query.findOneAndUpdate(conditions, update, options, callback) // executes
|
|
3286
3273
|
* query.findOneAndUpdate(conditions, update, options) // returns Query
|
|
@@ -3410,19 +3397,19 @@ Query.prototype._findOneAndUpdate = wrapThunk(function(callback) {
|
|
|
3410
3397
|
*
|
|
3411
3398
|
* - `findOneAndRemove()`
|
|
3412
3399
|
*
|
|
3413
|
-
* ####Available options
|
|
3400
|
+
* #### Available options
|
|
3414
3401
|
*
|
|
3415
3402
|
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
3416
3403
|
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
|
|
3417
3404
|
* - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
|
|
3418
3405
|
*
|
|
3419
|
-
* ####Callback Signature
|
|
3406
|
+
* #### Callback Signature
|
|
3420
3407
|
* function(error, doc) {
|
|
3421
3408
|
* // error: any errors that occurred
|
|
3422
3409
|
* // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
|
|
3423
3410
|
* }
|
|
3424
3411
|
*
|
|
3425
|
-
* ####Examples
|
|
3412
|
+
* #### Examples
|
|
3426
3413
|
*
|
|
3427
3414
|
* A.where().findOneAndRemove(conditions, options, callback) // executes
|
|
3428
3415
|
* A.where().findOneAndRemove(conditions, options) // return Query
|
|
@@ -3497,19 +3484,19 @@ Query.prototype.findOneAndRemove = function(conditions, options, callback) {
|
|
|
3497
3484
|
* this distinction is purely pedantic. You should use `findOneAndDelete()`
|
|
3498
3485
|
* unless you have a good reason not to.
|
|
3499
3486
|
*
|
|
3500
|
-
* ####Available options
|
|
3487
|
+
* #### Available options
|
|
3501
3488
|
*
|
|
3502
3489
|
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
3503
3490
|
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
|
|
3504
3491
|
* - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
|
|
3505
3492
|
*
|
|
3506
|
-
* ####Callback Signature
|
|
3493
|
+
* #### Callback Signature
|
|
3507
3494
|
* function(error, doc) {
|
|
3508
3495
|
* // error: any errors that occurred
|
|
3509
3496
|
* // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
|
|
3510
3497
|
* }
|
|
3511
3498
|
*
|
|
3512
|
-
* ####Examples
|
|
3499
|
+
* #### Examples
|
|
3513
3500
|
*
|
|
3514
3501
|
* A.where().findOneAndDelete(conditions, options, callback) // executes
|
|
3515
3502
|
* A.where().findOneAndDelete(conditions, options) // return Query
|
|
@@ -3616,19 +3603,19 @@ Query.prototype._findOneAndDelete = wrapThunk(function(callback) {
|
|
|
3616
3603
|
*
|
|
3617
3604
|
* - `findOneAndReplace()`
|
|
3618
3605
|
*
|
|
3619
|
-
* ####Available options
|
|
3606
|
+
* #### Available options
|
|
3620
3607
|
*
|
|
3621
3608
|
* - `sort`: if multiple docs are found by the conditions, sets the sort order to choose which doc to update
|
|
3622
3609
|
* - `maxTimeMS`: puts a time limit on the query - requires mongodb >= 2.6.0
|
|
3623
3610
|
* - `rawResult`: if true, resolves to the [raw result from the MongoDB driver](https://mongodb.github.io/node-mongodb-native/4.3/interfaces/ModifyResult.html)
|
|
3624
3611
|
*
|
|
3625
|
-
* ####Callback Signature
|
|
3612
|
+
* #### Callback Signature
|
|
3626
3613
|
* function(error, doc) {
|
|
3627
3614
|
* // error: any errors that occurred
|
|
3628
3615
|
* // doc: the document before updates are applied if `new: false`, or after updates if `new = true`
|
|
3629
3616
|
* }
|
|
3630
3617
|
*
|
|
3631
|
-
* ####Examples
|
|
3618
|
+
* #### Examples
|
|
3632
3619
|
*
|
|
3633
3620
|
* A.where().findOneAndReplace(filter, replacement, options, callback); // executes
|
|
3634
3621
|
* A.where().findOneAndReplace(filter, replacement, options); // return Query
|
|
@@ -4193,15 +4180,15 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
|
|
|
4193
4180
|
*
|
|
4194
4181
|
* - `update()`
|
|
4195
4182
|
*
|
|
4196
|
-
* ####Example
|
|
4183
|
+
* #### Example
|
|
4197
4184
|
*
|
|
4198
|
-
* Model.where({ _id: id }).update({ title: 'words' })
|
|
4185
|
+
* Model.where({ _id: id }).update({ title: 'words' });
|
|
4199
4186
|
*
|
|
4200
4187
|
* // becomes
|
|
4201
4188
|
*
|
|
4202
|
-
* Model.where({ _id: id }).update({ $set: { title: 'words' }})
|
|
4189
|
+
* Model.where({ _id: id }).update({ $set: { title: 'words' }});
|
|
4203
4190
|
*
|
|
4204
|
-
* ####Valid options:
|
|
4191
|
+
* #### Valid options:
|
|
4205
4192
|
*
|
|
4206
4193
|
* - `upsert` (boolean) whether to create the doc if it doesn't match (false)
|
|
4207
4194
|
* - `multi` (boolean) whether multiple documents should be updated (false)
|
|
@@ -4211,47 +4198,51 @@ Query.prototype._replaceOne = wrapThunk(function(callback) {
|
|
|
4211
4198
|
* - `read`
|
|
4212
4199
|
* - `writeConcern`
|
|
4213
4200
|
*
|
|
4214
|
-
* ####Note
|
|
4201
|
+
* #### Note
|
|
4215
4202
|
*
|
|
4216
4203
|
* Passing an empty object `{}` as the doc will result in a no-op. The update operation will be ignored and the callback executed without sending the command to MongoDB.
|
|
4217
4204
|
*
|
|
4218
|
-
* ####Note
|
|
4205
|
+
* #### Note
|
|
4219
4206
|
*
|
|
4220
4207
|
* The operation is only executed when a callback is passed. To force execution without a callback, we must first call update() and then execute it by using the `exec()` method.
|
|
4221
4208
|
*
|
|
4222
|
-
*
|
|
4223
|
-
*
|
|
4209
|
+
* ```javascript
|
|
4210
|
+
* const q = Model.where({ _id: id });
|
|
4211
|
+
* q.update({ $set: { name: 'bob' }}).update(); // not executed
|
|
4224
4212
|
*
|
|
4225
|
-
*
|
|
4213
|
+
* q.update({ $set: { name: 'bob' }}).exec(); // executed
|
|
4226
4214
|
*
|
|
4227
|
-
*
|
|
4228
|
-
*
|
|
4229
|
-
*
|
|
4215
|
+
* // keys that are not [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) ops become `$set`.
|
|
4216
|
+
* // this executes the same command as the previous example.
|
|
4217
|
+
* q.update({ name: 'bob' }).exec();
|
|
4230
4218
|
*
|
|
4231
|
-
*
|
|
4232
|
-
*
|
|
4233
|
-
*
|
|
4219
|
+
* // multi updates
|
|
4220
|
+
* Model.where()
|
|
4221
|
+
* .update({ name: /^match/ }, { $set: { arr: [] }}, { multi: true }, callback)
|
|
4234
4222
|
*
|
|
4235
|
-
*
|
|
4236
|
-
*
|
|
4237
|
-
*
|
|
4238
|
-
*
|
|
4223
|
+
* // more multi updates
|
|
4224
|
+
* Model.where()
|
|
4225
|
+
* .setOptions({ multi: true })
|
|
4226
|
+
* .update({ $set: { arr: [] }}, callback)
|
|
4239
4227
|
*
|
|
4240
|
-
*
|
|
4241
|
-
*
|
|
4242
|
-
*
|
|
4228
|
+
* // single update by default
|
|
4229
|
+
* Model.where({ email: 'address@example.com' })
|
|
4230
|
+
* .update({ $inc: { counter: 1 }}, callback)
|
|
4231
|
+
* ```
|
|
4243
4232
|
*
|
|
4244
4233
|
* API summary
|
|
4245
4234
|
*
|
|
4246
|
-
*
|
|
4247
|
-
*
|
|
4248
|
-
*
|
|
4249
|
-
*
|
|
4250
|
-
*
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4254
|
-
*
|
|
4235
|
+
* ```javascript
|
|
4236
|
+
* update(filter, doc, options, cb); // executes
|
|
4237
|
+
* update(filter, doc, options);
|
|
4238
|
+
* update(filter, doc, cb); // executes
|
|
4239
|
+
* update(filter, doc);
|
|
4240
|
+
* update(doc, cb); // executes
|
|
4241
|
+
* update(doc);
|
|
4242
|
+
* update(cb); // executes
|
|
4243
|
+
* update(true); // executes
|
|
4244
|
+
* update();
|
|
4245
|
+
* ```
|
|
4255
4246
|
*
|
|
4256
4247
|
* @param {Object} [filter]
|
|
4257
4248
|
* @param {Object} [doc] the update command
|
|
@@ -4308,7 +4299,7 @@ Query.prototype.update = function(conditions, doc, options, callback) {
|
|
|
4308
4299
|
* **Note** updateMany will _not_ fire update middleware. Use `pre('updateMany')`
|
|
4309
4300
|
* and `post('updateMany')` instead.
|
|
4310
4301
|
*
|
|
4311
|
-
* ####Example:
|
|
4302
|
+
* #### Example:
|
|
4312
4303
|
* const res = await Person.updateMany({ name: /Stark$/ }, { isDeleted: true });
|
|
4313
4304
|
* res.n; // Number of documents matched
|
|
4314
4305
|
* res.nModified; // Number of documents modified
|
|
@@ -4373,7 +4364,7 @@ Query.prototype.updateMany = function(conditions, doc, options, callback) {
|
|
|
4373
4364
|
* **Note** updateOne will _not_ fire update middleware. Use `pre('updateOne')`
|
|
4374
4365
|
* and `post('updateOne')` instead.
|
|
4375
4366
|
*
|
|
4376
|
-
* ####Example:
|
|
4367
|
+
* #### Example:
|
|
4377
4368
|
* const res = await Person.updateOne({ name: 'Jean-Luc Picard' }, { ship: 'USS Enterprise' });
|
|
4378
4369
|
* res.n; // Number of documents matched
|
|
4379
4370
|
* res.nModified; // Number of documents modified
|
|
@@ -4436,7 +4427,7 @@ Query.prototype.updateOne = function(conditions, doc, options, callback) {
|
|
|
4436
4427
|
* **Note** replaceOne will _not_ fire update middleware. Use `pre('replaceOne')`
|
|
4437
4428
|
* and `post('replaceOne')` instead.
|
|
4438
4429
|
*
|
|
4439
|
-
* ####Example:
|
|
4430
|
+
* #### Example:
|
|
4440
4431
|
* const res = await Person.replaceOne({ _id: 24601 }, { name: 'Jean Valjean' });
|
|
4441
4432
|
* res.n; // Number of documents matched
|
|
4442
4433
|
* res.nModified; // Number of documents modified
|
|
@@ -4540,7 +4531,7 @@ function _update(query, op, filter, doc, options, callback) {
|
|
|
4540
4531
|
*
|
|
4541
4532
|
* Any functions you pass to `transform()` will run **after** any post hooks.
|
|
4542
4533
|
*
|
|
4543
|
-
* ####Example:
|
|
4534
|
+
* #### Example:
|
|
4544
4535
|
*
|
|
4545
4536
|
* const res = await MyModel.findOne().transform(res => {
|
|
4546
4537
|
* // Sets a `loadedAt` property on the doc that tells you the time the
|
|
@@ -4567,7 +4558,7 @@ Query.prototype.transform = function(fn) {
|
|
|
4567
4558
|
* This is handy for integrating with async/await, because `orFail()` saves you
|
|
4568
4559
|
* an extra `if` statement to check if no document was found.
|
|
4569
4560
|
*
|
|
4570
|
-
* ####Example:
|
|
4561
|
+
* #### Example:
|
|
4571
4562
|
*
|
|
4572
4563
|
* // Throws if no doc returned
|
|
4573
4564
|
* await Model.findOne({ foo: 'bar' }).orFail();
|
|
@@ -4657,7 +4648,7 @@ function _orFailError(err, query) {
|
|
|
4657
4648
|
/**
|
|
4658
4649
|
* Executes the query
|
|
4659
4650
|
*
|
|
4660
|
-
* ####Examples:
|
|
4651
|
+
* #### Examples:
|
|
4661
4652
|
*
|
|
4662
4653
|
* const promise = query.exec();
|
|
4663
4654
|
* const promise = query.exec('update');
|
|
@@ -4797,7 +4788,7 @@ Query.prototype.catch = function(reject) {
|
|
|
4797
4788
|
* Add pre [middleware](/docs/middleware.html) to this query instance. Doesn't affect
|
|
4798
4789
|
* other queries.
|
|
4799
4790
|
*
|
|
4800
|
-
* ####Example:
|
|
4791
|
+
* #### Example:
|
|
4801
4792
|
*
|
|
4802
4793
|
* const q1 = Question.find({ answer: 42 });
|
|
4803
4794
|
* q1.pre(function middleware() {
|
|
@@ -4823,7 +4814,7 @@ Query.prototype.pre = function(fn) {
|
|
|
4823
4814
|
* Add post [middleware](/docs/middleware.html) to this query instance. Doesn't affect
|
|
4824
4815
|
* other queries.
|
|
4825
4816
|
*
|
|
4826
|
-
* ####Example:
|
|
4817
|
+
* #### Example:
|
|
4827
4818
|
*
|
|
4828
4819
|
* const q1 = Question.find({ answer: 42 });
|
|
4829
4820
|
* q1.post(function middleware() {
|
|
@@ -4922,7 +4913,7 @@ function castDoc(query, overwrite) {
|
|
|
4922
4913
|
/**
|
|
4923
4914
|
* Specifies paths which should be populated with other documents.
|
|
4924
4915
|
*
|
|
4925
|
-
* ####Example:
|
|
4916
|
+
* #### Example:
|
|
4926
4917
|
*
|
|
4927
4918
|
* let book = await Book.findOne().populate('authors');
|
|
4928
4919
|
* book.title; // 'Node.js in Action'
|
|
@@ -5029,14 +5020,14 @@ Query.prototype.populate = function() {
|
|
|
5029
5020
|
/**
|
|
5030
5021
|
* Gets a list of paths to be populated by this query
|
|
5031
5022
|
*
|
|
5032
|
-
* ####Example:
|
|
5023
|
+
* #### Example:
|
|
5033
5024
|
* bookSchema.pre('findOne', function() {
|
|
5034
5025
|
* let keys = this.getPopulatedPaths(); // ['author']
|
|
5035
5026
|
* });
|
|
5036
5027
|
* ...
|
|
5037
5028
|
* Book.findOne({}).populate('author');
|
|
5038
5029
|
*
|
|
5039
|
-
* ####Example:
|
|
5030
|
+
* #### Example:
|
|
5040
5031
|
* // Deep populate
|
|
5041
5032
|
* const q = L1.find().populate({
|
|
5042
5033
|
* path: 'level2',
|
|
@@ -5078,7 +5069,7 @@ function _getPopulatedPaths(list, arr, prefix) {
|
|
|
5078
5069
|
/**
|
|
5079
5070
|
* Casts this query to the schema of `model`
|
|
5080
5071
|
*
|
|
5081
|
-
* ####Note
|
|
5072
|
+
* #### Note
|
|
5082
5073
|
*
|
|
5083
5074
|
* If `obj` is present, it is cast instead of this query.
|
|
5084
5075
|
*
|
|
@@ -5203,7 +5194,7 @@ Query.prototype._applyPaths = function applyPaths() {
|
|
|
5203
5194
|
*
|
|
5204
5195
|
* The `.cursor()` function triggers pre find hooks, but **not** post find hooks.
|
|
5205
5196
|
*
|
|
5206
|
-
* ####Example
|
|
5197
|
+
* #### Example
|
|
5207
5198
|
*
|
|
5208
5199
|
* // There are 2 ways to use a cursor. First, as a stream:
|
|
5209
5200
|
* Thing.
|
|
@@ -5227,7 +5218,7 @@ Query.prototype._applyPaths = function applyPaths() {
|
|
|
5227
5218
|
* console.log(doc);
|
|
5228
5219
|
* }
|
|
5229
5220
|
*
|
|
5230
|
-
* ####Valid options
|
|
5221
|
+
* #### Valid options
|
|
5231
5222
|
*
|
|
5232
5223
|
* - `transform`: optional function which accepts a mongoose document. The return value of the function will be emitted on `data` and returned by `.next()`.
|
|
5233
5224
|
*
|
|
@@ -5274,7 +5265,7 @@ Query.prototype.maxscan = Query.base.maxScan;
|
|
|
5274
5265
|
/**
|
|
5275
5266
|
* Sets the tailable option (for use with capped collections).
|
|
5276
5267
|
*
|
|
5277
|
-
* ####Example
|
|
5268
|
+
* #### Example
|
|
5278
5269
|
*
|
|
5279
5270
|
* query.tailable(); // true
|
|
5280
5271
|
* query.tailable(true);
|
|
@@ -5283,7 +5274,7 @@ Query.prototype.maxscan = Query.base.maxScan;
|
|
|
5283
5274
|
* // Set both `tailable` and `awaitData` options
|
|
5284
5275
|
* query.tailable({ awaitData: true });
|
|
5285
5276
|
*
|
|
5286
|
-
* ####Note
|
|
5277
|
+
* #### Note
|
|
5287
5278
|
*
|
|
5288
5279
|
* Cannot be used with `distinct()`
|
|
5289
5280
|
*
|
|
@@ -5324,23 +5315,23 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5324
5315
|
/**
|
|
5325
5316
|
* Declares an intersects query for `geometry()`.
|
|
5326
5317
|
*
|
|
5327
|
-
* ####Example
|
|
5318
|
+
* #### Example
|
|
5328
5319
|
*
|
|
5329
5320
|
* query.where('path').intersects().geometry({
|
|
5330
|
-
*
|
|
5331
|
-
*
|
|
5332
|
-
* })
|
|
5321
|
+
* type: 'LineString',
|
|
5322
|
+
* coordinates: [[180.0, 11.0], [180, 9.0]]
|
|
5323
|
+
* });
|
|
5333
5324
|
*
|
|
5334
5325
|
* query.where('path').intersects({
|
|
5335
|
-
*
|
|
5336
|
-
*
|
|
5337
|
-
* })
|
|
5326
|
+
* type: 'LineString',
|
|
5327
|
+
* coordinates: [[180.0, 11.0], [180, 9.0]]
|
|
5328
|
+
* });
|
|
5338
5329
|
*
|
|
5339
|
-
* ####
|
|
5330
|
+
* #### Note:
|
|
5340
5331
|
*
|
|
5341
5332
|
* **MUST** be used after `where()`.
|
|
5342
5333
|
*
|
|
5343
|
-
* ####
|
|
5334
|
+
* #### Note:
|
|
5344
5335
|
*
|
|
5345
5336
|
* In Mongoose 3.7, `intersects` changed from a getter to a function. If you need the old syntax, use [this](https://github.com/ebensing/mongoose-within).
|
|
5346
5337
|
*
|
|
@@ -5357,7 +5348,7 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5357
5348
|
/**
|
|
5358
5349
|
* Specifies a `$geometry` condition
|
|
5359
5350
|
*
|
|
5360
|
-
* ####Example
|
|
5351
|
+
* #### Example
|
|
5361
5352
|
*
|
|
5362
5353
|
* const polyA = [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]]
|
|
5363
5354
|
* query.where('loc').within().geometry({ type: 'Polygon', coordinates: polyA })
|
|
@@ -5375,7 +5366,7 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5375
5366
|
*
|
|
5376
5367
|
* The argument is assigned to the most recent path passed to `where()`.
|
|
5377
5368
|
*
|
|
5378
|
-
* ####
|
|
5369
|
+
* #### Note:
|
|
5379
5370
|
*
|
|
5380
5371
|
* `geometry()` **must** come after either `intersects()` or `within()`.
|
|
5381
5372
|
*
|
|
@@ -5399,7 +5390,7 @@ Query.prototype.tailable = function(val, opts) {
|
|
|
5399
5390
|
*
|
|
5400
5391
|
* These operators return documents sorted by distance.
|
|
5401
5392
|
*
|
|
5402
|
-
* ####Example
|
|
5393
|
+
* #### Example
|
|
5403
5394
|
*
|
|
5404
5395
|
* query.where('loc').near({ center: [10, 10] });
|
|
5405
5396
|
* query.where('loc').near({ center: [10, 10], maxDistance: 5 });
|
|
@@ -5482,13 +5473,13 @@ Query.prototype.near = function() {
|
|
|
5482
5473
|
/**
|
|
5483
5474
|
* _DEPRECATED_ Specifies a `$nearSphere` condition
|
|
5484
5475
|
*
|
|
5485
|
-
* ####Example
|
|
5476
|
+
* #### Example
|
|
5486
5477
|
*
|
|
5487
5478
|
* query.where('loc').nearSphere({ center: [10, 10], maxDistance: 5 });
|
|
5488
5479
|
*
|
|
5489
5480
|
* **Deprecated.** Use `query.near()` instead with the `spherical` option set to `true`.
|
|
5490
5481
|
*
|
|
5491
|
-
* ####Example
|
|
5482
|
+
* #### Example
|
|
5492
5483
|
*
|
|
5493
5484
|
* query.where('loc').near({ center: [10, 10], spherical: true });
|
|
5494
5485
|
*
|
|
@@ -5511,7 +5502,7 @@ Query.prototype.nearSphere = function() {
|
|
|
5511
5502
|
* You do not need to call this function explicitly, the JavaScript runtime
|
|
5512
5503
|
* will call it for you.
|
|
5513
5504
|
*
|
|
5514
|
-
* ####Example
|
|
5505
|
+
* #### Example
|
|
5515
5506
|
*
|
|
5516
5507
|
* for await (const doc of Model.aggregate([{ $sort: { name: 1 } }])) {
|
|
5517
5508
|
* console.log(doc.name);
|
|
@@ -5539,10 +5530,10 @@ if (Symbol.asyncIterator != null) {
|
|
|
5539
5530
|
/**
|
|
5540
5531
|
* Specifies a `$polygon` condition
|
|
5541
5532
|
*
|
|
5542
|
-
* ####Example
|
|
5533
|
+
* #### Example
|
|
5543
5534
|
*
|
|
5544
|
-
* query.where('loc').within().polygon([10,20], [13, 25], [7,15])
|
|
5545
|
-
* query.polygon('loc', [10,20], [13, 25], [7,15])
|
|
5535
|
+
* query.where('loc').within().polygon([10, 20], [13, 25], [7, 15]);
|
|
5536
|
+
* query.polygon('loc', [10, 20], [13, 25], [7, 15]);
|
|
5546
5537
|
*
|
|
5547
5538
|
* @method polygon
|
|
5548
5539
|
* @memberOf Query
|
|
@@ -5558,7 +5549,7 @@ if (Symbol.asyncIterator != null) {
|
|
|
5558
5549
|
/**
|
|
5559
5550
|
* Specifies a `$box` condition
|
|
5560
5551
|
*
|
|
5561
|
-
* ####Example
|
|
5552
|
+
* #### Example
|
|
5562
5553
|
*
|
|
5563
5554
|
* const lowerLeft = [40.73083, -73.99756]
|
|
5564
5555
|
* const upperRight= [40.741404, -73.988135]
|
|
@@ -5595,7 +5586,7 @@ Query.prototype.box = function(ll, ur) {
|
|
|
5595
5586
|
/**
|
|
5596
5587
|
* Specifies a `$center` or `$centerSphere` condition.
|
|
5597
5588
|
*
|
|
5598
|
-
* ####Example
|
|
5589
|
+
* #### Example
|
|
5599
5590
|
*
|
|
5600
5591
|
* const area = { center: [50, 50], radius: 10, unique: true }
|
|
5601
5592
|
* query.where('loc').within().circle(area)
|
|
@@ -5640,7 +5631,7 @@ Query.prototype.center = Query.base.circle;
|
|
|
5640
5631
|
*
|
|
5641
5632
|
* **Deprecated.** Use [circle](#query_Query-circle) instead.
|
|
5642
5633
|
*
|
|
5643
|
-
* ####Example
|
|
5634
|
+
* #### Example
|
|
5644
5635
|
*
|
|
5645
5636
|
* const area = { center: [50, 50], radius: 10 };
|
|
5646
5637
|
* query.where('loc').within().centerSphere(area);
|
|
@@ -5679,9 +5670,9 @@ Query.prototype.centerSphere = function() {
|
|
|
5679
5670
|
/**
|
|
5680
5671
|
* Determines if inclusive field selection has been made.
|
|
5681
5672
|
*
|
|
5682
|
-
* query.selectedInclusively() // false
|
|
5683
|
-
* query.select('name')
|
|
5684
|
-
* query.selectedInclusively() // true
|
|
5673
|
+
* query.selectedInclusively(); // false
|
|
5674
|
+
* query.select('name');
|
|
5675
|
+
* query.selectedInclusively(); // true
|
|
5685
5676
|
*
|
|
5686
5677
|
* @method selectedInclusively
|
|
5687
5678
|
* @memberOf Query
|
|
@@ -5697,10 +5688,10 @@ Query.prototype.selectedInclusively = function selectedInclusively() {
|
|
|
5697
5688
|
/**
|
|
5698
5689
|
* Determines if exclusive field selection has been made.
|
|
5699
5690
|
*
|
|
5700
|
-
* query.selectedExclusively() // false
|
|
5701
|
-
* query.select('-name')
|
|
5702
|
-
* query.selectedExclusively() // true
|
|
5703
|
-
* query.selectedInclusively() // false
|
|
5691
|
+
* query.selectedExclusively(); // false
|
|
5692
|
+
* query.select('-name');
|
|
5693
|
+
* query.selectedExclusively(); // true
|
|
5694
|
+
* query.selectedInclusively(); // false
|
|
5704
5695
|
*
|
|
5705
5696
|
* @method selectedExclusively
|
|
5706
5697
|
* @memberOf Query
|