mongoose 5.13.6 → 5.13.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/History.md +11 -0
- package/index.d.ts +158 -139
- package/lib/query.js +16 -0
- package/lib/schema.js +1 -1
- package/package.json +1 -1
package/History.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
5.13.7 / 2021-08-11
|
|
2
|
+
===================
|
|
3
|
+
* perf(index.d.ts): loosen up restrictions on ModelType generic for Schema for a ~50% perf improvement when compiling TypeScript and using intellisense #10536 #10515 #10349
|
|
4
|
+
* fix(index.d.ts): fix broken `Schema#index()` types #10562 [JaredReisinger](https://github.com/JaredReisinger)
|
|
5
|
+
* fix(index.d.ts): allow using SchemaTypeOptions with array of raw document interfaces #10537
|
|
6
|
+
* fix(index.d.ts): define IndexOptions in terms of mongodb.IndexOptions #10563 [JaredReisinger](https://github.com/JaredReisinger)
|
|
7
|
+
* fix(index.d.ts): improve intellisense for DocumentArray `push()` #10546
|
|
8
|
+
* fix(index.d.ts): correct type for expires #10529
|
|
9
|
+
* fix(index.d.ts): add Query#model property to ts bindings #10531
|
|
10
|
+
* refactor(index.d.ts): make callbacks use the new Callback and CallbackWithoutResult types #10550 [thiagokisaki](https://github.com/thiagokisaki)
|
|
11
|
+
|
|
1
12
|
5.13.6 / 2021-08-09
|
|
2
13
|
===================
|
|
3
14
|
* fix: upgrade mongodb driver -> 3.6.11 #10543 [maon-fp](https://github.com/maon-fp)
|
package/index.d.ts
CHANGED
|
@@ -64,8 +64,8 @@ declare module 'mongoose' {
|
|
|
64
64
|
export const STATES: typeof ConnectionStates;
|
|
65
65
|
|
|
66
66
|
/** Opens Mongoose's default connection to MongoDB, see [connections docs](https://mongoosejs.com/docs/connections.html) */
|
|
67
|
-
export function connect(uri: string, options: ConnectOptions, callback:
|
|
68
|
-
export function connect(uri: string, callback:
|
|
67
|
+
export function connect(uri: string, options: ConnectOptions, callback: CallbackWithoutResult): void;
|
|
68
|
+
export function connect(uri: string, callback: CallbackWithoutResult): void;
|
|
69
69
|
export function connect(uri: string, options?: ConnectOptions): Promise<Mongoose>;
|
|
70
70
|
|
|
71
71
|
/** The Mongoose module's default connection. Equivalent to `mongoose.connections[0]`, see [`connections`](#mongoose_Mongoose-connections). */
|
|
@@ -79,7 +79,7 @@ declare module 'mongoose' {
|
|
|
79
79
|
/** Creates a Connection instance. */
|
|
80
80
|
export function createConnection(uri: string, options?: ConnectOptions): Connection & Promise<Connection>;
|
|
81
81
|
export function createConnection(): Connection;
|
|
82
|
-
export function createConnection(uri: string, options: ConnectOptions, callback:
|
|
82
|
+
export function createConnection(uri: string, options: ConnectOptions, callback: Callback<Connection>): void;
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* Removes the model named `name` from the default connection, if it exists.
|
|
@@ -89,7 +89,7 @@ declare module 'mongoose' {
|
|
|
89
89
|
export function deleteModel(name: string | RegExp): typeof mongoose;
|
|
90
90
|
|
|
91
91
|
export function disconnect(): Promise<void>;
|
|
92
|
-
export function disconnect(cb:
|
|
92
|
+
export function disconnect(cb: CallbackWithoutResult): void;
|
|
93
93
|
|
|
94
94
|
/** Gets mongoose options */
|
|
95
95
|
export function get<K extends keyof MongooseOptions>(key: K): MongooseOptions[K];
|
|
@@ -103,7 +103,13 @@ declare module 'mongoose' {
|
|
|
103
103
|
export function model<T>(name: string, schema?: Schema<any>, collection?: string, skipInit?: boolean): Model<T>;
|
|
104
104
|
export function model<T, U extends Model<T, TQueryHelpers, any>, TQueryHelpers = {}>(
|
|
105
105
|
name: string,
|
|
106
|
-
schema?: Schema<T, U>,
|
|
106
|
+
schema?: Schema<T, U, TQueryHelpers>,
|
|
107
|
+
collection?: string,
|
|
108
|
+
skipInit?: boolean
|
|
109
|
+
): U;
|
|
110
|
+
export function model<T, U extends Model<T, TQueryHelpers, any>, TQueryHelpers = {}>(
|
|
111
|
+
name: string,
|
|
112
|
+
schema?: Schema<any>,
|
|
107
113
|
collection?: string,
|
|
108
114
|
skipInit?: boolean
|
|
109
115
|
): U;
|
|
@@ -136,7 +142,7 @@ declare module 'mongoose' {
|
|
|
136
142
|
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
137
143
|
*/
|
|
138
144
|
export function startSession(options?: mongodb.SessionOptions): Promise<mongodb.ClientSession>;
|
|
139
|
-
export function startSession(options: mongodb.SessionOptions, cb:
|
|
145
|
+
export function startSession(options: mongodb.SessionOptions, cb: Callback<mongodb.ClientSession>): void;
|
|
140
146
|
|
|
141
147
|
/** The Mongoose version */
|
|
142
148
|
export const version: string;
|
|
@@ -302,8 +308,8 @@ declare module 'mongoose' {
|
|
|
302
308
|
|
|
303
309
|
class Connection extends events.EventEmitter {
|
|
304
310
|
/** Closes the connection */
|
|
305
|
-
close(callback:
|
|
306
|
-
close(force: boolean, callback:
|
|
311
|
+
close(callback: CallbackWithoutResult): void;
|
|
312
|
+
close(force: boolean, callback: CallbackWithoutResult): void;
|
|
307
313
|
close(force?: boolean): Promise<void>;
|
|
308
314
|
|
|
309
315
|
/** Retrieves a collection, creating it if not cached. */
|
|
@@ -324,8 +330,8 @@ declare module 'mongoose' {
|
|
|
324
330
|
* and [views](https://docs.mongodb.com/manual/core/views/) from mongoose.
|
|
325
331
|
*/
|
|
326
332
|
createCollection<T = any>(name: string, options?: mongodb.CollectionCreateOptions): Promise<mongodb.Collection<T>>;
|
|
327
|
-
createCollection<T = any>(name: string, cb:
|
|
328
|
-
createCollection<T = any>(name: string, options: mongodb.CollectionCreateOptions, cb?:
|
|
333
|
+
createCollection<T = any>(name: string, cb: Callback<mongodb.Collection<T>>): void;
|
|
334
|
+
createCollection<T = any>(name: string, options: mongodb.CollectionCreateOptions, cb?: Callback<mongodb.Collection>): Promise<mongodb.Collection<T>>;
|
|
329
335
|
|
|
330
336
|
/**
|
|
331
337
|
* Removes the model named `name` from this connection, if it exists. You can
|
|
@@ -339,14 +345,14 @@ declare module 'mongoose' {
|
|
|
339
345
|
* all documents and indexes.
|
|
340
346
|
*/
|
|
341
347
|
dropCollection(collection: string): Promise<void>;
|
|
342
|
-
dropCollection(collection: string, cb:
|
|
348
|
+
dropCollection(collection: string, cb: CallbackWithoutResult): void;
|
|
343
349
|
|
|
344
350
|
/**
|
|
345
351
|
* Helper for `dropDatabase()`. Deletes the given database, including all
|
|
346
352
|
* collections, documents, and indexes.
|
|
347
353
|
*/
|
|
348
354
|
dropDatabase(): Promise<void>;
|
|
349
|
-
dropDatabase(cb:
|
|
355
|
+
dropDatabase(cb: CallbackWithoutResult): void;
|
|
350
356
|
|
|
351
357
|
/** Gets the value of the option `key`. Equivalent to `conn.options[key]` */
|
|
352
358
|
get(key: string): any;
|
|
@@ -377,13 +383,19 @@ declare module 'mongoose' {
|
|
|
377
383
|
models: { [index: string]: Model<any> };
|
|
378
384
|
|
|
379
385
|
/** Defines or retrieves a model. */
|
|
380
|
-
model<T>(name: string, schema?: Schema<
|
|
386
|
+
model<T>(name: string, schema?: Schema<any>, collection?: string): Model<T>;
|
|
381
387
|
model<T, U extends Model<T, TQueryHelpers, any>, TQueryHelpers = {}>(
|
|
382
388
|
name: string,
|
|
383
389
|
schema?: Schema<T, U, TQueryHelpers>,
|
|
384
390
|
collection?: string,
|
|
385
391
|
skipInit?: boolean
|
|
386
392
|
): U;
|
|
393
|
+
model<T, U extends Model<T, TQueryHelpers, any>, TQueryHelpers = {}>(
|
|
394
|
+
name: string,
|
|
395
|
+
schema?: Schema<any>,
|
|
396
|
+
collection?: string,
|
|
397
|
+
skipInit?: boolean
|
|
398
|
+
): U;
|
|
387
399
|
|
|
388
400
|
/** Returns an array of model names created on this connection. */
|
|
389
401
|
modelNames(): Array<string>;
|
|
@@ -437,7 +449,7 @@ declare module 'mongoose' {
|
|
|
437
449
|
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
438
450
|
*/
|
|
439
451
|
startSession(options?: mongodb.SessionOptions): Promise<mongodb.ClientSession>;
|
|
440
|
-
startSession(options: mongodb.SessionOptions, cb:
|
|
452
|
+
startSession(options: mongodb.SessionOptions, cb: Callback<mongodb.ClientSession>): void;
|
|
441
453
|
|
|
442
454
|
/**
|
|
443
455
|
* _Requires MongoDB >= 3.6.0._ Executes the wrapped async function
|
|
@@ -576,13 +588,13 @@ declare module 'mongoose' {
|
|
|
576
588
|
|
|
577
589
|
/** Removes this document from the db. */
|
|
578
590
|
delete(options?: QueryOptions): QueryWithHelpers<any, this, TQueryHelpers>;
|
|
579
|
-
delete(options: QueryOptions, cb?:
|
|
580
|
-
delete(cb:
|
|
591
|
+
delete(options: QueryOptions, cb?: Callback): void;
|
|
592
|
+
delete(cb: Callback): void;
|
|
581
593
|
|
|
582
594
|
/** Removes this document from the db. */
|
|
583
595
|
deleteOne(options?: QueryOptions): QueryWithHelpers<any, this, TQueryHelpers>;
|
|
584
|
-
deleteOne(options: QueryOptions, cb?:
|
|
585
|
-
deleteOne(cb:
|
|
596
|
+
deleteOne(options: QueryOptions, cb?: Callback): void;
|
|
597
|
+
deleteOne(cb: Callback): void;
|
|
586
598
|
|
|
587
599
|
/** Takes a populated field and returns it to its unpopulated state. */
|
|
588
600
|
depopulate(path: string): this;
|
|
@@ -608,7 +620,7 @@ declare module 'mongoose' {
|
|
|
608
620
|
|
|
609
621
|
/** Explicitly executes population and returns a promise. Useful for promises integration. */
|
|
610
622
|
execPopulate(): Promise<this>;
|
|
611
|
-
execPopulate(callback:
|
|
623
|
+
execPopulate(callback: Callback<this>): void;
|
|
612
624
|
|
|
613
625
|
/** Returns the value of a path. */
|
|
614
626
|
get(path: string, type?: any, options?: any): any;
|
|
@@ -630,7 +642,7 @@ declare module 'mongoose' {
|
|
|
630
642
|
* Called internally after a document is returned from mongodb. Normally,
|
|
631
643
|
* you do **not** need to call this function on your own.
|
|
632
644
|
*/
|
|
633
|
-
init(obj: any, opts?: any, cb?:
|
|
645
|
+
init(obj: any, opts?: any, cb?: Callback<this>): this;
|
|
634
646
|
|
|
635
647
|
/** Marks a path as invalid, causing validation to fail. */
|
|
636
648
|
invalidate(path: string, errorMsg: string | NativeError, value?: any, kind?: string): NativeError | null;
|
|
@@ -686,25 +698,25 @@ declare module 'mongoose' {
|
|
|
686
698
|
* If you want to use promises instead, use this function with
|
|
687
699
|
* [`execPopulate()`](#document_Document-execPopulate).
|
|
688
700
|
*/
|
|
689
|
-
populate(path: string, callback?:
|
|
690
|
-
populate(path: string, names: string, callback?:
|
|
691
|
-
populate(opts: PopulateOptions | Array<PopulateOptions>, callback?:
|
|
701
|
+
populate(path: string, callback?: Callback<this>): this;
|
|
702
|
+
populate(path: string, names: string, callback?: Callback<this>): this;
|
|
703
|
+
populate(opts: PopulateOptions | Array<PopulateOptions>, callback?: Callback<this>): this;
|
|
692
704
|
|
|
693
705
|
/** Gets _id(s) used during population of the given `path`. If the path was not populated, returns `undefined`. */
|
|
694
706
|
populated(path: string): any;
|
|
695
707
|
|
|
696
708
|
/** Removes this document from the db. */
|
|
697
709
|
remove(options?: QueryOptions): Promise<this>;
|
|
698
|
-
remove(options?: QueryOptions, cb?:
|
|
710
|
+
remove(options?: QueryOptions, cb?: Callback): void;
|
|
699
711
|
|
|
700
712
|
/** Sends a replaceOne command with this document `_id` as the query selector. */
|
|
701
|
-
replaceOne(replacement?: DocumentDefinition<this>, options?: QueryOptions | null, callback?:
|
|
702
|
-
replaceOne(replacement?: Object, options?: QueryOptions | null, callback?:
|
|
713
|
+
replaceOne(replacement?: DocumentDefinition<this>, options?: QueryOptions | null, callback?: Callback): Query<any, this>;
|
|
714
|
+
replaceOne(replacement?: Object, options?: QueryOptions | null, callback?: Callback): Query<any, this>;
|
|
703
715
|
|
|
704
716
|
/** Saves this document by inserting a new document into the database if [document.isNew](/docs/api.html#document_Document-isNew) is `true`, or sends an [updateOne](/docs/api.html#document_Document-updateOne) operation with just the modified paths if `isNew` is `false`. */
|
|
705
717
|
save(options?: SaveOptions): Promise<this>;
|
|
706
|
-
save(options?: SaveOptions, fn?:
|
|
707
|
-
save(fn?:
|
|
718
|
+
save(options?: SaveOptions, fn?: Callback<this>): void;
|
|
719
|
+
save(fn?: Callback<this>): void;
|
|
708
720
|
|
|
709
721
|
/** The document's schema. */
|
|
710
722
|
schema: Schema;
|
|
@@ -726,17 +738,17 @@ declare module 'mongoose' {
|
|
|
726
738
|
unmarkModified(path: string): void;
|
|
727
739
|
|
|
728
740
|
/** Sends an update command with this document `_id` as the query selector. */
|
|
729
|
-
update(update?: UpdateQuery<this> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
741
|
+
update(update?: UpdateQuery<this> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback): Query<any, this>;
|
|
730
742
|
|
|
731
743
|
/** Sends an updateOne command with this document `_id` as the query selector. */
|
|
732
|
-
updateOne(update?: UpdateQuery<this> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
744
|
+
updateOne(update?: UpdateQuery<this> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback): Query<any, this>;
|
|
733
745
|
|
|
734
746
|
/** Executes registered validation rules for this document. */
|
|
735
747
|
validate(options:{ pathsToSkip?: pathsToSkip }): Promise<void>;
|
|
736
748
|
validate(pathsToValidate?: pathsToValidate, options?: any): Promise<void>;
|
|
737
|
-
validate(callback:
|
|
738
|
-
validate(pathsToValidate: pathsToValidate, callback:
|
|
739
|
-
validate(pathsToValidate: pathsToValidate, options: any, callback:
|
|
749
|
+
validate(callback: CallbackWithoutResult): void;
|
|
750
|
+
validate(pathsToValidate: pathsToValidate, callback: CallbackWithoutResult): void;
|
|
751
|
+
validate(pathsToValidate: pathsToValidate, options: any, callback: CallbackWithoutResult): void;
|
|
740
752
|
|
|
741
753
|
/** Executes registered validation rules (skipping asynchronous validators) for this document. */
|
|
742
754
|
validateSync(options:{pathsToSkip?: pathsToSkip, [k:string]: any }): Error.ValidationError | null;
|
|
@@ -750,8 +762,8 @@ declare module 'mongoose' {
|
|
|
750
762
|
|
|
751
763
|
interface AcceptsDiscriminator {
|
|
752
764
|
/** Adds a discriminator type. */
|
|
753
|
-
discriminator<D>(name: string | number, schema: Schema
|
|
754
|
-
discriminator<T, U
|
|
765
|
+
discriminator<D>(name: string | number, schema: Schema, value?: string | number | ObjectId): Model<D>;
|
|
766
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
|
|
755
767
|
}
|
|
756
768
|
|
|
757
769
|
type AnyKeys<T> = { [P in keyof T]?: T[P] | any };
|
|
@@ -789,29 +801,29 @@ declare module 'mongoose' {
|
|
|
789
801
|
* trip to MongoDB.
|
|
790
802
|
*/
|
|
791
803
|
bulkWrite(writes: Array<any>, options?: mongodb.CollectionBulkWriteOptions): Promise<mongodb.BulkWriteOpResultObject>;
|
|
792
|
-
bulkWrite(writes: Array<any>, options?: mongodb.CollectionBulkWriteOptions, cb?:
|
|
804
|
+
bulkWrite(writes: Array<any>, options?: mongodb.CollectionBulkWriteOptions, cb?: Callback<mongodb.BulkWriteOpResultObject>): void;
|
|
793
805
|
|
|
794
806
|
/** Collection the model uses. */
|
|
795
807
|
collection: Collection;
|
|
796
808
|
|
|
797
809
|
/** Creates a `count` query: counts the number of documents that match `filter`. */
|
|
798
|
-
count(callback?:
|
|
799
|
-
count(filter: FilterQuery<T>, callback?:
|
|
810
|
+
count(callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
811
|
+
count(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
800
812
|
|
|
801
813
|
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
802
|
-
countDocuments(callback?:
|
|
803
|
-
countDocuments(filter: FilterQuery<T>, callback?:
|
|
814
|
+
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
815
|
+
countDocuments(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
804
816
|
|
|
805
817
|
/** Creates a new document or documents */
|
|
806
818
|
create(docs: (T | DocumentDefinition<T> | AnyObject)[], options?: SaveOptions): Promise<EnforceDocument<T, TMethods>[]>;
|
|
807
|
-
create(docs: (T | DocumentDefinition<T> | AnyObject)[], callback:
|
|
819
|
+
create(docs: (T | DocumentDefinition<T> | AnyObject)[], callback: Callback<EnforceDocument<T, TMethods>[]>): void;
|
|
808
820
|
create(doc: T | DocumentDefinition<T> | AnyObject): Promise<EnforceDocument<T, TMethods>>;
|
|
809
|
-
create(doc: T | DocumentDefinition<T> | AnyObject, callback:
|
|
821
|
+
create(doc: T | DocumentDefinition<T> | AnyObject, callback: Callback<EnforceDocument<T, TMethods>>): void;
|
|
810
822
|
create<DocContents = T | DocumentDefinition<T>>(docs: DocContents[], options?: SaveOptions): Promise<EnforceDocument<T, TMethods>[]>;
|
|
811
|
-
create<DocContents = T | DocumentDefinition<T>>(docs: DocContents[], callback:
|
|
823
|
+
create<DocContents = T | DocumentDefinition<T>>(docs: DocContents[], callback: Callback<EnforceDocument<T, TMethods>[]>): void;
|
|
812
824
|
create<DocContents = T | DocumentDefinition<T>>(doc: DocContents): Promise<EnforceDocument<T, TMethods>>;
|
|
813
825
|
create<DocContents = T | DocumentDefinition<T>>(...docs: DocContents[]): Promise<EnforceDocument<T, TMethods>[]>;
|
|
814
|
-
create<DocContents = T | DocumentDefinition<T>>(doc: DocContents, callback:
|
|
826
|
+
create<DocContents = T | DocumentDefinition<T>>(doc: DocContents, callback: Callback<EnforceDocument<T, TMethods>>): void;
|
|
815
827
|
|
|
816
828
|
/**
|
|
817
829
|
* Create the collection for this model. By default, if no indexes are specified,
|
|
@@ -819,14 +831,14 @@ declare module 'mongoose' {
|
|
|
819
831
|
* created. Use this method to create the collection explicitly.
|
|
820
832
|
*/
|
|
821
833
|
createCollection(options?: mongodb.CollectionCreateOptions): Promise<mongodb.Collection<T>>;
|
|
822
|
-
createCollection(options: mongodb.CollectionCreateOptions | null, callback:
|
|
834
|
+
createCollection(options: mongodb.CollectionCreateOptions | null, callback: Callback<mongodb.Collection<T>>): void;
|
|
823
835
|
|
|
824
836
|
/**
|
|
825
837
|
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#createIndex)
|
|
826
838
|
* function.
|
|
827
839
|
*/
|
|
828
|
-
createIndexes(callback?:
|
|
829
|
-
createIndexes(options?: any, callback?:
|
|
840
|
+
createIndexes(callback?: CallbackWithoutResult): Promise<void>;
|
|
841
|
+
createIndexes(options?: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
830
842
|
|
|
831
843
|
/** Connection the model uses. */
|
|
832
844
|
db: Connection;
|
|
@@ -836,25 +848,25 @@ declare module 'mongoose' {
|
|
|
836
848
|
* Behaves like `remove()`, but deletes all documents that match `conditions`
|
|
837
849
|
* regardless of the `single` option.
|
|
838
850
|
*/
|
|
839
|
-
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions, callback?:
|
|
840
|
-
deleteMany(filter: FilterQuery<T>, callback:
|
|
841
|
-
deleteMany(callback:
|
|
851
|
+
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
852
|
+
deleteMany(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
853
|
+
deleteMany(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
842
854
|
|
|
843
855
|
/**
|
|
844
856
|
* Deletes the first document that matches `conditions` from the collection.
|
|
845
857
|
* Behaves like `remove()`, but deletes at most one document regardless of the
|
|
846
858
|
* `single` option.
|
|
847
859
|
*/
|
|
848
|
-
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions, callback?:
|
|
849
|
-
deleteOne(filter: FilterQuery<T>, callback:
|
|
850
|
-
deleteOne(callback:
|
|
860
|
+
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
861
|
+
deleteOne(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
862
|
+
deleteOne(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteWriteOpResultObject['result'] & { deletedCount?: number }, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
851
863
|
|
|
852
864
|
/**
|
|
853
865
|
* Sends `createIndex` commands to mongo for each index declared in the schema.
|
|
854
866
|
* The `createIndex` commands are sent in series.
|
|
855
867
|
*/
|
|
856
|
-
ensureIndexes(callback?:
|
|
857
|
-
ensureIndexes(options?: any, callback?:
|
|
868
|
+
ensureIndexes(callback?: CallbackWithoutResult): Promise<void>;
|
|
869
|
+
ensureIndexes(options?: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
858
870
|
|
|
859
871
|
/**
|
|
860
872
|
* Event emitter that reports any errors that occurred. Useful for global error
|
|
@@ -867,10 +879,10 @@ declare module 'mongoose' {
|
|
|
867
879
|
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
868
880
|
* `_id`, use `findById()` instead of `findOne()`.
|
|
869
881
|
*/
|
|
870
|
-
findById(id: any, projection?: any | null, options?: QueryOptions | null, callback?:
|
|
882
|
+
findById(id: any, projection?: any | null, options?: QueryOptions | null, callback?: Callback<EnforceDocument<T, TMethods> | null>): QueryWithHelpers<EnforceDocument<T, TMethods> | null, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
871
883
|
|
|
872
884
|
/** Finds one document. */
|
|
873
|
-
findOne(filter?: FilterQuery<T>, projection?: any | null, options?: QueryOptions | null, callback?:
|
|
885
|
+
findOne(filter?: FilterQuery<T>, projection?: any | null, options?: QueryOptions | null, callback?: Callback<EnforceDocument<T, TMethods> | null>): QueryWithHelpers<EnforceDocument<T, TMethods> | null, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
874
886
|
|
|
875
887
|
/**
|
|
876
888
|
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
@@ -886,15 +898,15 @@ declare module 'mongoose' {
|
|
|
886
898
|
* [`connection.model()`](/docs/api.html#connection_Connection-model), so you
|
|
887
899
|
* don't need to call it.
|
|
888
900
|
*/
|
|
889
|
-
init(callback?:
|
|
901
|
+
init(callback?: CallbackWithoutResult): Promise<EnforceDocument<T, TMethods>>;
|
|
890
902
|
|
|
891
903
|
/** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */
|
|
892
904
|
insertMany(docs: Array<T | DocumentDefinition<T> | AnyObject>, options: InsertManyOptions & { rawResult: true }): Promise<InsertManyResult>;
|
|
893
905
|
insertMany(docs: Array<T | DocumentDefinition<T> | AnyObject>, options?: InsertManyOptions): Promise<Array<EnforceDocument<T, TMethods>>>;
|
|
894
906
|
insertMany(doc: T | DocumentDefinition<T> | AnyObject, options: InsertManyOptions & { rawResult: true }): Promise<InsertManyResult>;
|
|
895
907
|
insertMany(doc: T | DocumentDefinition<T> | AnyObject, options?: InsertManyOptions): Promise<EnforceDocument<T, TMethods>>;
|
|
896
|
-
insertMany(doc: T | DocumentDefinition<T> | AnyObject, options?: InsertManyOptions, callback?:
|
|
897
|
-
insertMany(docs: Array<T | DocumentDefinition<T> | AnyObject>, options?: InsertManyOptions, callback?:
|
|
908
|
+
insertMany(doc: T | DocumentDefinition<T> | AnyObject, options?: InsertManyOptions, callback?: Callback<EnforceDocument<T, TMethods> | InsertManyResult>): void;
|
|
909
|
+
insertMany(docs: Array<T | DocumentDefinition<T> | AnyObject>, options?: InsertManyOptions, callback?: Callback<Array<EnforceDocument<T, TMethods>> | InsertManyResult>): void;
|
|
898
910
|
|
|
899
911
|
/**
|
|
900
912
|
* Lists the indexes currently defined in MongoDB. This may or may not be
|
|
@@ -902,7 +914,7 @@ declare module 'mongoose' {
|
|
|
902
914
|
* use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you
|
|
903
915
|
* build indexes manually.
|
|
904
916
|
*/
|
|
905
|
-
listIndexes(callback:
|
|
917
|
+
listIndexes(callback: Callback<Array<any>>): void;
|
|
906
918
|
listIndexes(): Promise<Array<any>>;
|
|
907
919
|
|
|
908
920
|
/** The name of the model */
|
|
@@ -910,9 +922,9 @@ declare module 'mongoose' {
|
|
|
910
922
|
|
|
911
923
|
/** Populates document references. */
|
|
912
924
|
populate(docs: Array<any>, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
913
|
-
callback?: (
|
|
925
|
+
callback?: Callback<(EnforceDocument<T, TMethods>)[]>): Promise<Array<EnforceDocument<T, TMethods>>>;
|
|
914
926
|
populate(doc: any, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
915
|
-
callback?:
|
|
927
|
+
callback?: Callback<EnforceDocument<T, TMethods>>): Promise<EnforceDocument<T, TMethods>>;
|
|
916
928
|
|
|
917
929
|
/**
|
|
918
930
|
* Makes the indexes in MongoDB match the indexes defined in this model's
|
|
@@ -921,7 +933,7 @@ declare module 'mongoose' {
|
|
|
921
933
|
* are in your schema but not in MongoDB.
|
|
922
934
|
*/
|
|
923
935
|
syncIndexes(options?: Record<string, unknown>): Promise<Array<string>>;
|
|
924
|
-
syncIndexes(options: Record<string, unknown> | null, callback:
|
|
936
|
+
syncIndexes(options: Record<string, unknown> | null, callback: Callback<Array<string>>): void;
|
|
925
937
|
|
|
926
938
|
/**
|
|
927
939
|
* Does a dry-run of Model.syncIndexes(), meaning that
|
|
@@ -936,12 +948,12 @@ declare module 'mongoose' {
|
|
|
936
948
|
* for benefits like causal consistency, [retryable writes](https://docs.mongodb.com/manual/core/retryable-writes/),
|
|
937
949
|
* and [transactions](http://thecodebarbarian.com/a-node-js-perspective-on-mongodb-4-transactions.html).
|
|
938
950
|
* */
|
|
939
|
-
startSession(options?: mongodb.SessionOptions, cb?:
|
|
951
|
+
startSession(options?: mongodb.SessionOptions, cb?: Callback<mongodb.ClientSession>): Promise<mongodb.ClientSession>;
|
|
940
952
|
|
|
941
953
|
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
942
|
-
validate(callback?:
|
|
943
|
-
validate(optional: any, callback?:
|
|
944
|
-
validate(optional: any, pathsToValidate: string[], callback?:
|
|
954
|
+
validate(callback?: CallbackWithoutResult): Promise<void>;
|
|
955
|
+
validate(optional: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
956
|
+
validate(optional: any, pathsToValidate: string[], callback?: CallbackWithoutResult): Promise<void>;
|
|
945
957
|
|
|
946
958
|
/** Watches the underlying collection for changes using [MongoDB change streams](https://docs.mongodb.com/manual/changeStreams/). */
|
|
947
959
|
watch(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream;
|
|
@@ -956,22 +968,22 @@ declare module 'mongoose' {
|
|
|
956
968
|
translateAliases(raw: any): any;
|
|
957
969
|
|
|
958
970
|
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
959
|
-
distinct(field: string, filter?: FilterQuery<T>, callback?:
|
|
971
|
+
distinct(field: string, filter?: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<Array<any>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
960
972
|
|
|
961
973
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
962
|
-
estimatedDocumentCount(options?: QueryOptions, callback?:
|
|
974
|
+
estimatedDocumentCount(options?: QueryOptions, callback?: Callback<number>): QueryWithHelpers<number, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
963
975
|
|
|
964
976
|
/**
|
|
965
977
|
* Returns true if at least one document exists in the database that matches
|
|
966
978
|
* the given `filter`, and false otherwise.
|
|
967
979
|
*/
|
|
968
980
|
exists(filter: FilterQuery<T>): Promise<boolean>;
|
|
969
|
-
exists(filter: FilterQuery<T>, callback:
|
|
981
|
+
exists(filter: FilterQuery<T>, callback: Callback<boolean>): void;
|
|
970
982
|
|
|
971
983
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
972
|
-
find(callback?:
|
|
973
|
-
find(filter: FilterQuery<T>, callback?:
|
|
974
|
-
find(filter: FilterQuery<T>, projection?: any | null, options?: QueryOptions | null, callback?:
|
|
984
|
+
find(callback?: Callback<EnforceDocument<T, TMethods>[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
985
|
+
find(filter: FilterQuery<T>, callback?: Callback<T[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
986
|
+
find(filter: FilterQuery<T>, projection?: any | null, options?: QueryOptions | null, callback?: Callback<EnforceDocument<T, TMethods>[]>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
975
987
|
|
|
976
988
|
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
977
989
|
findByIdAndDelete(id?: mongodb.ObjectId | any, options?: QueryOptions | null, callback?: (err: CallbackError, doc: EnforceDocument<T, TMethods> | null, res: any) => void): QueryWithHelpers<EnforceDocument<T, TMethods> | null, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
@@ -1000,19 +1012,19 @@ declare module 'mongoose' {
|
|
|
1000
1012
|
findOneAndUpdate(filter: FilterQuery<T>, update: UpdateQuery<T> | UpdateWithAggregationPipeline, options: QueryOptions & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: EnforceDocument<T, TMethods>, res: any) => void): QueryWithHelpers<EnforceDocument<T, TMethods>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1001
1013
|
findOneAndUpdate(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: (err: CallbackError, doc: EnforceDocument<T, TMethods> | null, res: any) => void): QueryWithHelpers<EnforceDocument<T, TMethods> | null, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1002
1014
|
|
|
1003
|
-
geoSearch(filter?: FilterQuery<T>, options?: GeoSearchOptions, callback?:
|
|
1015
|
+
geoSearch(filter?: FilterQuery<T>, options?: GeoSearchOptions, callback?: Callback<Array<EnforceDocument<T, TMethods>>>): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1004
1016
|
|
|
1005
1017
|
/** Executes a mapReduce command. */
|
|
1006
1018
|
mapReduce<Key, Value>(
|
|
1007
1019
|
o: MapReduceOptions<T, Key, Value>,
|
|
1008
|
-
callback?:
|
|
1020
|
+
callback?: Callback
|
|
1009
1021
|
): Promise<any>;
|
|
1010
1022
|
|
|
1011
|
-
remove(filter?: any, callback?:
|
|
1023
|
+
remove(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1012
1024
|
|
|
1013
1025
|
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
1014
|
-
replaceOne(filter?: FilterQuery<T>, replacement?: DocumentDefinition<T>, options?: QueryOptions | null, callback?:
|
|
1015
|
-
replaceOne(filter?: FilterQuery<T>, replacement?: Object, options?: QueryOptions | null, callback?:
|
|
1026
|
+
replaceOne(filter?: FilterQuery<T>, replacement?: DocumentDefinition<T>, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1027
|
+
replaceOne(filter?: FilterQuery<T>, replacement?: Object, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1016
1028
|
|
|
1017
1029
|
/** Schema the model uses. */
|
|
1018
1030
|
schema: Schema;
|
|
@@ -1021,13 +1033,13 @@ declare module 'mongoose' {
|
|
|
1021
1033
|
* @deprecated use `updateOne` or `updateMany` instead.
|
|
1022
1034
|
* Creates a `update` query: updates one or many documents that match `filter` with `update`, based on the `multi` option.
|
|
1023
1035
|
*/
|
|
1024
|
-
update(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
1036
|
+
update(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1025
1037
|
|
|
1026
1038
|
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
1027
|
-
updateMany(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
1039
|
+
updateMany(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1028
1040
|
|
|
1029
1041
|
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
1030
|
-
updateOne(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
1042
|
+
updateOne(filter?: FilterQuery<T>, update?: UpdateQuery<T> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<UpdateWriteOpResult, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
1031
1043
|
|
|
1032
1044
|
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
1033
1045
|
where(path: string, val?: any): QueryWithHelpers<Array<EnforceDocument<T, TMethods>>, EnforceDocument<T, TMethods>, TQueryHelpers, T>;
|
|
@@ -1243,15 +1255,17 @@ declare module 'mongoose' {
|
|
|
1243
1255
|
type SchemaPreOptions = { document?: boolean, query?: boolean };
|
|
1244
1256
|
type SchemaPostOptions = { document?: boolean, query?: boolean };
|
|
1245
1257
|
|
|
1246
|
-
type ExtractQueryHelpers<M> = M extends Model<any, infer TQueryHelpers> ? TQueryHelpers : {};
|
|
1247
1258
|
type ExtractMethods<M> = M extends Model<any, any, infer TMethods> ? TMethods : {};
|
|
1248
1259
|
|
|
1260
|
+
type IndexDirection = 1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text';
|
|
1261
|
+
type IndexDefinition = Record<string, IndexDirection>;
|
|
1262
|
+
|
|
1249
1263
|
type PreMiddlewareFunction<T> = (this: T, next: (err?: CallbackError) => void) => void | Promise<void>;
|
|
1250
1264
|
type PreSaveMiddlewareFunction<T> = (this: T, next: (err?: CallbackError) => void, opts: SaveOptions) => void | Promise<void>;
|
|
1251
1265
|
type PostMiddlewareFunction<ThisType, ResType = any> = (this: ThisType, res: ResType, next: (err?: CallbackError) => void) => void | Promise<void>;
|
|
1252
1266
|
type ErrorHandlingMiddlewareFunction<ThisType, ResType = any> = (this: ThisType, err: NativeError, res: ResType, next: (err?: CallbackError) => void) => void;
|
|
1253
1267
|
|
|
1254
|
-
class Schema<DocType = Document, M
|
|
1268
|
+
class Schema<DocType = Document, M = Model<DocType, any, any>, SchemaDefinitionType = undefined, TInstanceMethods = {}> extends events.EventEmitter {
|
|
1255
1269
|
/**
|
|
1256
1270
|
* Create a new schema
|
|
1257
1271
|
*/
|
|
@@ -1277,13 +1291,13 @@ declare module 'mongoose' {
|
|
|
1277
1291
|
eachPath(fn: (path: string, type: SchemaType) => void): this;
|
|
1278
1292
|
|
|
1279
1293
|
/** Defines an index (most likely compound) for this schema. */
|
|
1280
|
-
index(fields:
|
|
1294
|
+
index(fields: IndexDefinition, options?: IndexOptions): this;
|
|
1281
1295
|
|
|
1282
1296
|
/**
|
|
1283
1297
|
* Returns a list of indexes that this schema declares, via `schema.index()`
|
|
1284
1298
|
* or by `index: true` in a path's options.
|
|
1285
1299
|
*/
|
|
1286
|
-
indexes(): Array<
|
|
1300
|
+
indexes(): Array<IndexDefinition>;
|
|
1287
1301
|
|
|
1288
1302
|
/** Gets a schema option. */
|
|
1289
1303
|
get<K extends keyof SchemaOptions>(key: K): SchemaOptions[K];
|
|
@@ -1329,8 +1343,8 @@ declare module 'mongoose' {
|
|
|
1329
1343
|
post<T extends Query<any, any> = Query<any, any>>(method: MongooseQueryMiddleware | MongooseQueryMiddleware[] | string | RegExp, options: SchemaPostOptions, fn: PostMiddlewareFunction<T>): this;
|
|
1330
1344
|
post<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, fn: PostMiddlewareFunction<T, Array<any>>): this;
|
|
1331
1345
|
post<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, options: SchemaPostOptions, fn: PostMiddlewareFunction<T, Array<any>>): this;
|
|
1332
|
-
post<T
|
|
1333
|
-
post<T
|
|
1346
|
+
post<T = M>(method: 'insertMany' | RegExp, fn: PostMiddlewareFunction<T>): this;
|
|
1347
|
+
post<T = M>(method: 'insertMany' | RegExp, options: SchemaPostOptions, fn: PostMiddlewareFunction<T>): this;
|
|
1334
1348
|
|
|
1335
1349
|
post<T = EnforceDocument<DocType, TInstanceMethods>>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, fn: ErrorHandlingMiddlewareFunction<T>): this;
|
|
1336
1350
|
post<T = EnforceDocument<DocType, TInstanceMethods>>(method: MongooseDocumentMiddleware | MongooseDocumentMiddleware[] | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T>): this;
|
|
@@ -1338,8 +1352,8 @@ declare module 'mongoose' {
|
|
|
1338
1352
|
post<T extends Query<any, any> = Query<any, any>>(method: MongooseQueryMiddleware | MongooseQueryMiddleware[] | string | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T>): this;
|
|
1339
1353
|
post<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, fn: ErrorHandlingMiddlewareFunction<T, Array<any>>): this;
|
|
1340
1354
|
post<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T, Array<any>>): this;
|
|
1341
|
-
post<T
|
|
1342
|
-
post<T
|
|
1355
|
+
post<T = M>(method: 'insertMany' | RegExp, fn: ErrorHandlingMiddlewareFunction<T>): this;
|
|
1356
|
+
post<T = M>(method: 'insertMany' | RegExp, options: SchemaPostOptions, fn: ErrorHandlingMiddlewareFunction<T>): this;
|
|
1343
1357
|
|
|
1344
1358
|
/** Defines a pre hook for the model. */
|
|
1345
1359
|
pre<T = EnforceDocument<DocType, TInstanceMethods>>(method: 'save', fn: PreSaveMiddlewareFunction<T>): this;
|
|
@@ -1349,11 +1363,11 @@ declare module 'mongoose' {
|
|
|
1349
1363
|
pre<T extends Query<any, any> = Query<any, any>>(method: MongooseQueryMiddleware | MongooseQueryMiddleware[] | string | RegExp, options: SchemaPreOptions, fn: PreMiddlewareFunction<T>): this;
|
|
1350
1364
|
pre<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, fn: PreMiddlewareFunction<T>): this;
|
|
1351
1365
|
pre<T extends Aggregate<any> = Aggregate<any>>(method: 'aggregate' | RegExp, options: SchemaPreOptions, fn: PreMiddlewareFunction<T>): this;
|
|
1352
|
-
pre<T
|
|
1353
|
-
pre<T
|
|
1366
|
+
pre<T = M>(method: 'insertMany' | RegExp, fn: (this: T, next: (err?: CallbackError) => void, docs: any | Array<any>) => void | Promise<void>): this;
|
|
1367
|
+
pre<T = M>(method: 'insertMany' | RegExp, options: SchemaPreOptions, fn: (this: T, next: (err?: CallbackError) => void, docs: any | Array<any>) => void | Promise<void>): this;
|
|
1354
1368
|
|
|
1355
1369
|
/** Object of currently defined query helpers on this schema. */
|
|
1356
|
-
query: { [name: string]:
|
|
1370
|
+
query: { [name: string]: Function };
|
|
1357
1371
|
|
|
1358
1372
|
/** Adds a method call to the queue. */
|
|
1359
1373
|
queue(name: string, args: any[]): this;
|
|
@@ -1580,7 +1594,7 @@ declare module 'mongoose' {
|
|
|
1580
1594
|
type?:
|
|
1581
1595
|
T extends string | number | boolean | NativeDate | Function ? SchemaDefinitionWithBuiltInClass<T> :
|
|
1582
1596
|
T extends Schema<any, any> ? T :
|
|
1583
|
-
T extends object[] ? (Schema<
|
|
1597
|
+
T extends object[] ? (Schema<Unpacked<T>>[] | ReadonlyArray<Schema<Unpacked<T>>> | Schema<Document & Unpacked<T>>[] | ReadonlyArray<Schema<Document & Unpacked<T>>>) :
|
|
1584
1598
|
T extends string[] ? (SchemaDefinitionWithBuiltInClass<string>[] | ReadonlyArray<SchemaDefinitionWithBuiltInClass<string>>) :
|
|
1585
1599
|
T extends number[] ? (SchemaDefinitionWithBuiltInClass<number>[] | ReadonlyArray<SchemaDefinitionWithBuiltInClass<number>>) :
|
|
1586
1600
|
T extends boolean[] ? (SchemaDefinitionWithBuiltInClass<boolean>[] | ReadonlyArray<SchemaDefinitionWithBuiltInClass<boolean>>) :
|
|
@@ -1677,7 +1691,7 @@ declare module 'mongoose' {
|
|
|
1677
1691
|
max?: number | NativeDate | [number, string] | [NativeDate, string] | readonly [number, string] | readonly [NativeDate, string];
|
|
1678
1692
|
|
|
1679
1693
|
/** Defines a TTL index on this path. Only allowed for dates. */
|
|
1680
|
-
expires?:
|
|
1694
|
+
expires?: string | number;
|
|
1681
1695
|
|
|
1682
1696
|
/** If `true`, Mongoose will skip gathering indexes on subpaths. Only allowed for subdocuments and subdocument arrays. */
|
|
1683
1697
|
excludeIndexes?: boolean;
|
|
@@ -1732,12 +1746,8 @@ declare module 'mongoose' {
|
|
|
1732
1746
|
RawId extends RefType = (PopulatedType extends { _id?: RefType; } ? NonNullable<PopulatedType['_id']> : mongoose.Types.ObjectId) | undefined
|
|
1733
1747
|
> = PopulatedType | RawId;
|
|
1734
1748
|
|
|
1735
|
-
interface IndexOptions {
|
|
1736
|
-
background?: boolean,
|
|
1749
|
+
interface IndexOptions extends mongodb.IndexOptions {
|
|
1737
1750
|
expires?: number | string
|
|
1738
|
-
sparse?: boolean,
|
|
1739
|
-
type?: string,
|
|
1740
|
-
unique?: boolean
|
|
1741
1751
|
}
|
|
1742
1752
|
|
|
1743
1753
|
interface ValidatorProps {
|
|
@@ -1840,8 +1850,8 @@ declare module 'mongoose' {
|
|
|
1840
1850
|
|
|
1841
1851
|
static options: { castNonArrays: boolean; };
|
|
1842
1852
|
|
|
1843
|
-
discriminator<D>(name: string | number, schema: Schema
|
|
1844
|
-
discriminator<T, U
|
|
1853
|
+
discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
|
|
1854
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
|
|
1845
1855
|
|
|
1846
1856
|
/**
|
|
1847
1857
|
* Adds an enum validator if this is an array of strings or numbers. Equivalent to
|
|
@@ -1897,8 +1907,8 @@ declare module 'mongoose' {
|
|
|
1897
1907
|
|
|
1898
1908
|
static options: { castNonArrays: boolean; };
|
|
1899
1909
|
|
|
1900
|
-
discriminator<D>(name: string | number, schema: Schema
|
|
1901
|
-
discriminator<T, U
|
|
1910
|
+
discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
|
|
1911
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
|
|
1902
1912
|
|
|
1903
1913
|
/** The schema used for documents in this array */
|
|
1904
1914
|
schema: Schema;
|
|
@@ -1943,8 +1953,8 @@ declare module 'mongoose' {
|
|
|
1943
1953
|
/** The document's schema */
|
|
1944
1954
|
schema: Schema;
|
|
1945
1955
|
|
|
1946
|
-
discriminator<D>(name: string | number, schema: Schema
|
|
1947
|
-
discriminator<T, U
|
|
1956
|
+
discriminator<D>(name: string | number, schema: Schema, value?: string): Model<D>;
|
|
1957
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string): U;
|
|
1948
1958
|
}
|
|
1949
1959
|
|
|
1950
1960
|
class String extends SchemaType {
|
|
@@ -2041,6 +2051,8 @@ declare module 'mongoose' {
|
|
|
2041
2051
|
|
|
2042
2052
|
/** Searches array items for the first document with a matching _id. */
|
|
2043
2053
|
id(id: any): T | null;
|
|
2054
|
+
|
|
2055
|
+
push(...args: (AnyKeys<T> & AnyObject)[]): number;
|
|
2044
2056
|
}
|
|
2045
2057
|
|
|
2046
2058
|
class EmbeddedDocument extends Document {
|
|
@@ -2108,9 +2120,9 @@ declare module 'mongoose' {
|
|
|
2108
2120
|
|
|
2109
2121
|
/** Executes the query */
|
|
2110
2122
|
exec(): Promise<ResultType>;
|
|
2111
|
-
exec(callback?:
|
|
2123
|
+
exec(callback?: Callback<ResultType>): void;
|
|
2112
2124
|
// @todo: this doesn't seem right
|
|
2113
|
-
exec(callback?:
|
|
2125
|
+
exec(callback?: Callback<ResultType>): Promise<ResultType> | any;
|
|
2114
2126
|
|
|
2115
2127
|
$where(argument: string | Function): QueryWithHelpers<DocType[], DocType, THelpers, RawDocType>;
|
|
2116
2128
|
|
|
@@ -2155,12 +2167,12 @@ declare module 'mongoose' {
|
|
|
2155
2167
|
comment(val: string): this;
|
|
2156
2168
|
|
|
2157
2169
|
/** Specifies this query as a `count` query. */
|
|
2158
|
-
count(callback?:
|
|
2159
|
-
count(criteria: FilterQuery<DocType>, callback?:
|
|
2170
|
+
count(callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
2171
|
+
count(criteria: FilterQuery<DocType>, callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
2160
2172
|
|
|
2161
2173
|
/** Specifies this query as a `countDocuments` query. */
|
|
2162
|
-
countDocuments(callback?:
|
|
2163
|
-
countDocuments(criteria: FilterQuery<DocType>, callback?:
|
|
2174
|
+
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
2175
|
+
countDocuments(criteria: FilterQuery<DocType>, callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
2164
2176
|
|
|
2165
2177
|
/**
|
|
2166
2178
|
* Returns a wrapper around a [mongodb driver cursor](http://mongodb.github.io/node-mongodb-native/2.1/api/Cursor.html).
|
|
@@ -2173,21 +2185,21 @@ declare module 'mongoose' {
|
|
|
2173
2185
|
* remove, except it deletes _every_ document that matches `filter` in the
|
|
2174
2186
|
* collection, regardless of the value of `single`.
|
|
2175
2187
|
*/
|
|
2176
|
-
deleteMany(filter?: FilterQuery<DocType>, options?: QueryOptions, callback?:
|
|
2177
|
-
deleteMany(filter: FilterQuery<DocType>, callback:
|
|
2178
|
-
deleteMany(callback:
|
|
2188
|
+
deleteMany(filter?: FilterQuery<DocType>, options?: QueryOptions, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2189
|
+
deleteMany(filter: FilterQuery<DocType>, callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2190
|
+
deleteMany(callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2179
2191
|
|
|
2180
2192
|
/**
|
|
2181
2193
|
* Declare and/or execute this query as a `deleteOne()` operation. Works like
|
|
2182
2194
|
* remove, except it deletes at most one document regardless of the `single`
|
|
2183
2195
|
* option.
|
|
2184
2196
|
*/
|
|
2185
|
-
deleteOne(filter?: FilterQuery<DocType>, options?: QueryOptions, callback?:
|
|
2186
|
-
deleteOne(filter: FilterQuery<DocType>, callback:
|
|
2187
|
-
deleteOne(callback:
|
|
2197
|
+
deleteOne(filter?: FilterQuery<DocType>, options?: QueryOptions, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2198
|
+
deleteOne(filter: FilterQuery<DocType>, callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2199
|
+
deleteOne(callback: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2188
2200
|
|
|
2189
2201
|
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
2190
|
-
distinct(field: string, filter?: FilterQuery<DocType>, callback?:
|
|
2202
|
+
distinct(field: string, filter?: FilterQuery<DocType>, callback?: Callback<number>): QueryWithHelpers<Array<any>, DocType, THelpers, RawDocType>;
|
|
2191
2203
|
|
|
2192
2204
|
/** Specifies a `$elemMatch` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
2193
2205
|
elemMatch(val: Function | any): this;
|
|
@@ -2204,7 +2216,7 @@ declare module 'mongoose' {
|
|
|
2204
2216
|
equals(val: any): this;
|
|
2205
2217
|
|
|
2206
2218
|
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
2207
|
-
estimatedDocumentCount(options?: QueryOptions, callback?:
|
|
2219
|
+
estimatedDocumentCount(options?: QueryOptions, callback?: Callback<number>): QueryWithHelpers<number, DocType, THelpers, RawDocType>;
|
|
2208
2220
|
|
|
2209
2221
|
/** Specifies a `$exists` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
|
2210
2222
|
exists(val: boolean): this;
|
|
@@ -2219,12 +2231,12 @@ declare module 'mongoose' {
|
|
|
2219
2231
|
explain(verbose?: string): this;
|
|
2220
2232
|
|
|
2221
2233
|
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
2222
|
-
find(callback?:
|
|
2223
|
-
find(filter: FilterQuery<DocType>, callback?:
|
|
2224
|
-
find(filter: FilterQuery<DocType>, projection?: any | null, options?: QueryOptions | null, callback?:
|
|
2234
|
+
find(callback?: Callback<DocType[]>): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
2235
|
+
find(filter: FilterQuery<DocType>, callback?: Callback<DocType[]>): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
2236
|
+
find(filter: FilterQuery<DocType>, projection?: any | null, options?: QueryOptions | null, callback?: Callback<DocType[]>): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType>;
|
|
2225
2237
|
|
|
2226
2238
|
/** Declares the query a findOne operation. When executed, the first found document is passed to the callback. */
|
|
2227
|
-
findOne(filter?: FilterQuery<DocType>, projection?: any | null, options?: QueryOptions | null, callback?:
|
|
2239
|
+
findOne(filter?: FilterQuery<DocType>, projection?: any | null, options?: QueryOptions | null, callback?: Callback<DocType | null>): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
2228
2240
|
|
|
2229
2241
|
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
2230
2242
|
findOneAndDelete(filter?: FilterQuery<DocType>, options?: QueryOptions | null, callback?: (err: CallbackError, doc: DocType | null, res: any) => void): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType>;
|
|
@@ -2332,6 +2344,9 @@ declare module 'mongoose' {
|
|
|
2332
2344
|
mod(val: Array<number>): this;
|
|
2333
2345
|
mod(path: string, val: Array<number>): this;
|
|
2334
2346
|
|
|
2347
|
+
/** The model this query was created from */
|
|
2348
|
+
model: typeof Model;
|
|
2349
|
+
|
|
2335
2350
|
/**
|
|
2336
2351
|
* Getter/setter around the current mongoose-specific options for this query
|
|
2337
2352
|
* Below are the current Mongoose-specific options.
|
|
@@ -2389,15 +2404,15 @@ declare module 'mongoose' {
|
|
|
2389
2404
|
* deprecated, you should use [`deleteOne()`](#query_Query-deleteOne)
|
|
2390
2405
|
* or [`deleteMany()`](#query_Query-deleteMany) instead.
|
|
2391
2406
|
*/
|
|
2392
|
-
remove(filter?: FilterQuery<DocType>, callback?:
|
|
2407
|
+
remove(filter?: FilterQuery<DocType>, callback?: Callback<mongodb.WriteOpResult['result']>): QueryWithHelpers<mongodb.WriteOpResult['result'], DocType, THelpers, RawDocType>;
|
|
2393
2408
|
|
|
2394
2409
|
/**
|
|
2395
2410
|
* Declare and/or execute this query as a replaceOne() operation. Same as
|
|
2396
2411
|
* `update()`, except MongoDB will replace the existing document and will
|
|
2397
2412
|
* not accept any [atomic](https://docs.mongodb.com/manual/tutorial/model-data-for-atomic-operations/#pattern) operators (`$set`, etc.)
|
|
2398
2413
|
*/
|
|
2399
|
-
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocumentDefinition<DocType>, options?: QueryOptions | null, callback?:
|
|
2400
|
-
replaceOne(filter?: FilterQuery<DocType>, replacement?: Object, options?: QueryOptions | null, callback?:
|
|
2414
|
+
replaceOne(filter?: FilterQuery<DocType>, replacement?: DocumentDefinition<DocType>, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2415
|
+
replaceOne(filter?: FilterQuery<DocType>, replacement?: Object, options?: QueryOptions | null, callback?: Callback): QueryWithHelpers<any, DocType, THelpers, RawDocType>;
|
|
2401
2416
|
|
|
2402
2417
|
/** Specifies which document fields to include or exclude (also known as the query "projection") */
|
|
2403
2418
|
select(arg: string | any): this;
|
|
@@ -2466,7 +2481,7 @@ declare module 'mongoose' {
|
|
|
2466
2481
|
toConstructor(): new (...args: any[]) => QueryWithHelpers<ResultType, DocType, THelpers, RawDocType>;
|
|
2467
2482
|
|
|
2468
2483
|
/** Declare and/or execute this query as an update() operation. */
|
|
2469
|
-
update(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
2484
|
+
update(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2470
2485
|
|
|
2471
2486
|
/**
|
|
2472
2487
|
* Declare and/or execute this query as an updateMany() operation. Same as
|
|
@@ -2474,13 +2489,13 @@ declare module 'mongoose' {
|
|
|
2474
2489
|
* `filter` (as opposed to just the first one) regardless of the value of
|
|
2475
2490
|
* the `multi` option.
|
|
2476
2491
|
*/
|
|
2477
|
-
updateMany(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
2492
|
+
updateMany(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2478
2493
|
|
|
2479
2494
|
/**
|
|
2480
2495
|
* Declare and/or execute this query as an updateOne() operation. Same as
|
|
2481
2496
|
* `update()`, except it does not support the `multi` or `overwrite` options.
|
|
2482
2497
|
*/
|
|
2483
|
-
updateOne(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?:
|
|
2498
|
+
updateOne(filter?: FilterQuery<DocType>, update?: UpdateQuery<DocType> | UpdateWithAggregationPipeline, options?: QueryOptions | null, callback?: Callback<UpdateWriteOpResult>): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType>;
|
|
2484
2499
|
|
|
2485
2500
|
/**
|
|
2486
2501
|
* Sets the specified number of `mongod` servers, or tag set of `mongod` servers,
|
|
@@ -2625,7 +2640,7 @@ declare module 'mongoose' {
|
|
|
2625
2640
|
* `next()` will error.
|
|
2626
2641
|
*/
|
|
2627
2642
|
close(): Promise<void>;
|
|
2628
|
-
close(callback:
|
|
2643
|
+
close(callback: CallbackWithoutResult): void;
|
|
2629
2644
|
|
|
2630
2645
|
/**
|
|
2631
2646
|
* Execute `fn` for every document(s) in the cursor. If batchSize is provided
|
|
@@ -2635,8 +2650,8 @@ declare module 'mongoose' {
|
|
|
2635
2650
|
*/
|
|
2636
2651
|
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number }): Promise<void>;
|
|
2637
2652
|
eachAsync(fn: (doc: DocType[]) => any, options: { parallel?: number, batchSize: number }): Promise<void>;
|
|
2638
|
-
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number, batchSize?: number }, cb?:
|
|
2639
|
-
eachAsync(fn: (doc: DocType[]) => any, options: { parallel?: number, batchSize: number }, cb?:
|
|
2653
|
+
eachAsync(fn: (doc: DocType) => any, options?: { parallel?: number, batchSize?: number }, cb?: CallbackWithoutResult): void;
|
|
2654
|
+
eachAsync(fn: (doc: DocType[]) => any, options: { parallel?: number, batchSize: number }, cb?: CallbackWithoutResult): void;
|
|
2640
2655
|
|
|
2641
2656
|
/**
|
|
2642
2657
|
* Registers a transform function which subsequently maps documents retrieved
|
|
@@ -2649,7 +2664,7 @@ declare module 'mongoose' {
|
|
|
2649
2664
|
* no documents left.
|
|
2650
2665
|
*/
|
|
2651
2666
|
next(): Promise<DocType>;
|
|
2652
|
-
next(callback:
|
|
2667
|
+
next(callback: Callback<DocType | null>): void;
|
|
2653
2668
|
|
|
2654
2669
|
options: any;
|
|
2655
2670
|
}
|
|
@@ -2691,10 +2706,10 @@ declare module 'mongoose' {
|
|
|
2691
2706
|
cursor(options?: Record<string, unknown>): this;
|
|
2692
2707
|
|
|
2693
2708
|
/** Executes the aggregate pipeline on the currently bound Model. If cursor option is set, returns a cursor */
|
|
2694
|
-
exec(callback?:
|
|
2709
|
+
exec(callback?: Callback<R>): Promise<R> | any;
|
|
2695
2710
|
|
|
2696
2711
|
/** Execute the aggregation with explain */
|
|
2697
|
-
explain(callback?:
|
|
2712
|
+
explain(callback?: Callback): Promise<any>;
|
|
2698
2713
|
|
|
2699
2714
|
/** Combines multiple aggregation pipelines. */
|
|
2700
2715
|
facet(options: any): this;
|
|
@@ -2802,7 +2817,7 @@ declare module 'mongoose' {
|
|
|
2802
2817
|
* `next()` will error.
|
|
2803
2818
|
*/
|
|
2804
2819
|
close(): Promise<void>;
|
|
2805
|
-
close(callback:
|
|
2820
|
+
close(callback: CallbackWithoutResult): void;
|
|
2806
2821
|
|
|
2807
2822
|
/**
|
|
2808
2823
|
* Execute `fn` for every document(s) in the cursor. If batchSize is provided
|
|
@@ -2811,7 +2826,7 @@ declare module 'mongoose' {
|
|
|
2811
2826
|
* Returns a promise that resolves when done.
|
|
2812
2827
|
*/
|
|
2813
2828
|
eachAsync(fn: (doc: any) => any, options?: { parallel?: number, batchSize?: number }): Promise<void>;
|
|
2814
|
-
eachAsync(fn: (doc: any) => any, options?: { parallel?: number, batchSize?: number }, cb?:
|
|
2829
|
+
eachAsync(fn: (doc: any) => any, options?: { parallel?: number, batchSize?: number }, cb?: CallbackWithoutResult): void;
|
|
2815
2830
|
|
|
2816
2831
|
/**
|
|
2817
2832
|
* Registers a transform function which subsequently maps documents retrieved
|
|
@@ -2824,7 +2839,7 @@ declare module 'mongoose' {
|
|
|
2824
2839
|
* no documents left.
|
|
2825
2840
|
*/
|
|
2826
2841
|
next(): Promise<any>;
|
|
2827
|
-
next(callback:
|
|
2842
|
+
next(callback: Callback): void;
|
|
2828
2843
|
}
|
|
2829
2844
|
|
|
2830
2845
|
class SchemaType {
|
|
@@ -2898,6 +2913,10 @@ declare module 'mongoose' {
|
|
|
2898
2913
|
type?: string): this;
|
|
2899
2914
|
}
|
|
2900
2915
|
|
|
2916
|
+
type Callback<T = any> = (error: CallbackError, result: T) => void;
|
|
2917
|
+
|
|
2918
|
+
type CallbackWithoutResult = (error: CallbackError) => void;
|
|
2919
|
+
|
|
2901
2920
|
class NativeError extends global.Error { }
|
|
2902
2921
|
type CallbackError = NativeError | null;
|
|
2903
2922
|
|
package/lib/query.js
CHANGED
|
@@ -5543,6 +5543,22 @@ Query.prototype.selectedExclusively = function selectedExclusively() {
|
|
|
5543
5543
|
return isExclusive(this._fields);
|
|
5544
5544
|
};
|
|
5545
5545
|
|
|
5546
|
+
/**
|
|
5547
|
+
* The model this query is associated with.
|
|
5548
|
+
*
|
|
5549
|
+
* #### Example:
|
|
5550
|
+
*
|
|
5551
|
+
* const q = MyModel.find();
|
|
5552
|
+
* q.model === MyModel; // true
|
|
5553
|
+
*
|
|
5554
|
+
* @api public
|
|
5555
|
+
* @property model
|
|
5556
|
+
* @memberOf Query
|
|
5557
|
+
* @instance
|
|
5558
|
+
*/
|
|
5559
|
+
|
|
5560
|
+
Query.prototype.model;
|
|
5561
|
+
|
|
5546
5562
|
/*!
|
|
5547
5563
|
* Export
|
|
5548
5564
|
*/
|
package/lib/schema.js
CHANGED
|
@@ -1555,7 +1555,7 @@ Schema.prototype.static = function(name, fn) {
|
|
|
1555
1555
|
*
|
|
1556
1556
|
* @param {Object} fields
|
|
1557
1557
|
* @param {Object} [options] Options to pass to [MongoDB driver's `createIndex()` function](http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#createIndex)
|
|
1558
|
-
* @param {String} [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
|
|
1558
|
+
* @param {String | number} [options.expires=null] Mongoose-specific syntactic sugar, uses [ms](https://www.npmjs.com/package/ms) to convert `expires` option into seconds for the `expireAfterSeconds` in the above link.
|
|
1559
1559
|
* @api public
|
|
1560
1560
|
*/
|
|
1561
1561
|
|