mongoose 6.3.4 → 6.3.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/.eslintrc.json +1 -1
- package/dist/browser.umd.js +1 -1
- package/lgtm.yml +12 -0
- package/lib/cast/objectid.js +3 -2
- package/lib/connection.js +3 -2
- package/lib/document.js +37 -24
- package/lib/error/index.js +2 -2
- package/lib/helpers/clone.js +7 -1
- package/lib/helpers/common.js +3 -4
- package/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +2 -2
- package/lib/helpers/isBsonType.js +5 -3
- package/lib/helpers/path/setDottedPath.js +14 -1
- package/lib/helpers/schematype/handleImmutable.js +2 -1
- package/lib/helpers/topology/isAtlas.js +15 -2
- package/lib/helpers/update/applyTimestampsToChildren.js +4 -0
- package/lib/helpers/update/castArrayFilters.js +3 -0
- package/lib/index.js +4 -3
- package/lib/options/SchemaTypeOptions.js +13 -0
- package/lib/query.js +4 -1
- package/lib/schema/SubdocumentPath.js +8 -1
- package/lib/schema/decimal128.js +4 -4
- package/lib/schema/documentarray.js +2 -4
- package/lib/schema/map.js +8 -0
- package/lib/schema/objectid.js +4 -3
- package/lib/schema/string.js +2 -2
- package/lib/schema.js +33 -2
- package/lib/schematype.js +1 -0
- package/lib/types/DocumentArray/methods/index.js +3 -3
- package/lib/types/array/methods/index.js +3 -3
- package/lib/types/map.js +4 -4
- package/lib/utils.js +3 -4
- package/package.json +17 -15
- package/types/aggregate.d.ts +3 -4
- package/types/callback.d.ts +8 -0
- package/types/collection.d.ts +46 -0
- package/types/connection.d.ts +91 -71
- package/types/document.d.ts +1 -1
- package/types/error.d.ts +5 -1
- package/types/helpers.d.ts +32 -0
- package/types/index.d.ts +32 -1859
- package/types/indizes.d.ts +98 -0
- package/types/middlewares.d.ts +14 -0
- package/types/models.d.ts +419 -0
- package/types/populate.d.ts +40 -0
- package/types/query.d.ts +637 -0
- package/types/schematypes.d.ts +427 -0
- package/types/session.d.ts +36 -0
- package/types/types.d.ts +102 -0
- package/types/utility.d.ts +13 -0
- package/types/validation.d.ts +32 -0
- package/.lgtm.yml +0 -3
- package/CHANGELOG.md +0 -7300
- package/History.md +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Makes the indexes in MongoDB match the indexes defined in every model's
|
|
6
|
+
* schema. This function will drop any indexes that are not defined in
|
|
7
|
+
* the model's schema except the `_id` index, and build any indexes that
|
|
8
|
+
* are in your schema but not in MongoDB.
|
|
9
|
+
*/
|
|
10
|
+
function syncIndexes(options?: SyncIndexesOptions): Promise<ConnectionSyncIndexesResult>;
|
|
11
|
+
function syncIndexes(options: SyncIndexesOptions | null, callback: Callback<ConnectionSyncIndexesResult>): void;
|
|
12
|
+
|
|
13
|
+
interface IndexManager {
|
|
14
|
+
/**
|
|
15
|
+
* Similar to `ensureIndexes()`, except for it uses the [`createIndex`](http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#createIndex)
|
|
16
|
+
* function.
|
|
17
|
+
*/
|
|
18
|
+
createIndexes(options: mongodb.CreateIndexesOptions, callback: CallbackWithoutResult): void;
|
|
19
|
+
createIndexes(callback: CallbackWithoutResult): void;
|
|
20
|
+
createIndexes(options?: mongodb.CreateIndexesOptions): Promise<void>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Does a dry-run of Model.syncIndexes(), meaning that
|
|
24
|
+
* the result of this function would be the result of
|
|
25
|
+
* Model.syncIndexes().
|
|
26
|
+
*/
|
|
27
|
+
diffIndexes(options: Record<string, unknown> | null, callback: Callback<IndexesDiff>): void
|
|
28
|
+
diffIndexes(callback: Callback<IndexesDiff>): void
|
|
29
|
+
diffIndexes(options?: Record<string, unknown>): Promise<IndexesDiff>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sends `createIndex` commands to mongo for each index declared in the schema.
|
|
33
|
+
* The `createIndex` commands are sent in series.
|
|
34
|
+
*/
|
|
35
|
+
ensureIndexes(options: mongodb.CreateIndexesOptions, callback: CallbackWithoutResult): void;
|
|
36
|
+
ensureIndexes(callback: CallbackWithoutResult): void;
|
|
37
|
+
ensureIndexes(options?: mongodb.CreateIndexesOptions): Promise<void>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Lists the indexes currently defined in MongoDB. This may or may not be
|
|
41
|
+
* the same as the indexes defined in your schema depending on whether you
|
|
42
|
+
* use the [`autoIndex` option](/docs/guide.html#autoIndex) and if you
|
|
43
|
+
* build indexes manually.
|
|
44
|
+
*/
|
|
45
|
+
listIndexes(callback: Callback<Array<any>>): void;
|
|
46
|
+
listIndexes(): Promise<Array<any>>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Makes the indexes in MongoDB match the indexes defined in this model's
|
|
50
|
+
* schema. This function will drop any indexes that are not defined in
|
|
51
|
+
* the model's schema except the `_id` index, and build any indexes that
|
|
52
|
+
* are in your schema but not in MongoDB.
|
|
53
|
+
*/
|
|
54
|
+
syncIndexes(options: mongodb.CreateIndexesOptions | null, callback: Callback<Array<string>>): void;
|
|
55
|
+
syncIndexes(options?: mongodb.CreateIndexesOptions): Promise<Array<string>>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface IndexesDiff {
|
|
59
|
+
/** Indexes that would be created in mongodb. */
|
|
60
|
+
toCreate: Array<any>
|
|
61
|
+
/** Indexes that would be dropped in mongodb. */
|
|
62
|
+
toDrop: Array<any>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type IndexDirection = 1 | -1 | '2d' | '2dsphere' | 'geoHaystack' | 'hashed' | 'text';
|
|
66
|
+
type IndexDefinition = Record<string, IndexDirection>;
|
|
67
|
+
|
|
68
|
+
interface SyncIndexesOptions extends mongodb.CreateIndexesOptions {
|
|
69
|
+
continueOnError?: boolean
|
|
70
|
+
}
|
|
71
|
+
type ConnectionSyncIndexesResult = Record<string, OneCollectionSyncIndexesResult>;
|
|
72
|
+
type OneCollectionSyncIndexesResult = Array<string> & mongodb.MongoServerError;
|
|
73
|
+
|
|
74
|
+
interface IndexOptions extends mongodb.CreateIndexesOptions {
|
|
75
|
+
/**
|
|
76
|
+
* `expires` utilizes the `ms` module from [guille](https://github.com/guille/) allowing us to use a friendlier syntax:
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```js
|
|
80
|
+
* const schema = new Schema({ prop1: Date });
|
|
81
|
+
*
|
|
82
|
+
* // expire in 24 hours
|
|
83
|
+
* schema.index({ prop1: 1 }, { expires: 60*60*24 })
|
|
84
|
+
*
|
|
85
|
+
* // expire in 24 hours
|
|
86
|
+
* schema.index({ prop1: 1 }, { expires: '24h' })
|
|
87
|
+
*
|
|
88
|
+
* // expire in 1.5 hours
|
|
89
|
+
* schema.index({ prop1: 1 }, { expires: '1.5h' })
|
|
90
|
+
*
|
|
91
|
+
* // expire in 7 days
|
|
92
|
+
* schema.index({ prop1: 1 }, { expires: '7d' })
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
expires?: number | string;
|
|
96
|
+
weights?: AnyObject;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
|
|
3
|
+
type MongooseDocumentMiddleware = 'validate' | 'save' | 'remove' | 'updateOne' | 'deleteOne' | 'init';
|
|
4
|
+
type MongooseQueryMiddleware = 'count' | 'deleteMany' | 'deleteOne' | 'distinct' | 'find' | 'findOne' | 'findOneAndDelete' | 'findOneAndRemove' | 'findOneAndUpdate' | 'remove' | 'update' | 'updateOne' | 'updateMany';
|
|
5
|
+
|
|
6
|
+
type MiddlewareOptions = { document?: boolean, query?: boolean };
|
|
7
|
+
type SchemaPreOptions = MiddlewareOptions;
|
|
8
|
+
type SchemaPostOptions = MiddlewareOptions;
|
|
9
|
+
|
|
10
|
+
type PreMiddlewareFunction<ThisType = any> = (this: ThisType, next: CallbackWithoutResultAndOptionalError) => void | Promise<void>;
|
|
11
|
+
type PreSaveMiddlewareFunction<ThisType = any> = (this: ThisType, next: CallbackWithoutResultAndOptionalError, opts: SaveOptions) => void | Promise<void>;
|
|
12
|
+
type PostMiddlewareFunction<ThisType = any, ResType = any> = (this: ThisType, res: ResType, next: CallbackWithoutResultAndOptionalError) => void | Promise<void>;
|
|
13
|
+
type ErrorHandlingMiddlewareFunction<ThisType = any, ResType = any> = (this: ThisType, err: NativeError, res: ResType, next: CallbackWithoutResultAndOptionalError) => void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
import mongodb = require('mongodb');
|
|
3
|
+
|
|
4
|
+
export interface AcceptsDiscriminator {
|
|
5
|
+
/** Adds a discriminator type. */
|
|
6
|
+
discriminator<D>(name: string | number, schema: Schema, value?: string | number | ObjectId): Model<D>;
|
|
7
|
+
discriminator<T, U>(name: string | number, schema: Schema<T, U>, value?: string | number | ObjectId): U;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface MongooseBulkWriteOptions {
|
|
11
|
+
skipValidation?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface InsertManyOptions extends
|
|
15
|
+
PopulateOption,
|
|
16
|
+
SessionOption {
|
|
17
|
+
limit?: number;
|
|
18
|
+
rawResult?: boolean;
|
|
19
|
+
ordered?: boolean;
|
|
20
|
+
lean?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type InsertManyResult<T> = mongodb.InsertManyResult<T> & {
|
|
24
|
+
insertedIds: {
|
|
25
|
+
[key: number]: InferId<T>;
|
|
26
|
+
};
|
|
27
|
+
mongoose?: { validationErrors?: Array<Error.CastError | Error.ValidatorError> };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type UpdateWriteOpResult = mongodb.UpdateResult;
|
|
31
|
+
|
|
32
|
+
interface MapReduceOptions<T, K, R> {
|
|
33
|
+
map: Function | string;
|
|
34
|
+
reduce: (key: K, vals: T[]) => R;
|
|
35
|
+
/** query filter object. */
|
|
36
|
+
query?: any;
|
|
37
|
+
/** sort input objects using this key */
|
|
38
|
+
sort?: any;
|
|
39
|
+
/** max number of documents */
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** keep temporary data default: false */
|
|
42
|
+
keeptemp?: boolean;
|
|
43
|
+
/** finalize function */
|
|
44
|
+
finalize?: (key: K, val: R) => R;
|
|
45
|
+
/** scope variables exposed to map/reduce/finalize during execution */
|
|
46
|
+
scope?: any;
|
|
47
|
+
/** it is possible to make the execution stay in JS. Provided in MongoDB > 2.0.X default: false */
|
|
48
|
+
jsMode?: boolean;
|
|
49
|
+
/** provide statistics on job execution time. default: false */
|
|
50
|
+
verbose?: boolean;
|
|
51
|
+
readPreference?: string;
|
|
52
|
+
/** sets the output target for the map reduce job. default: {inline: 1} */
|
|
53
|
+
out?: {
|
|
54
|
+
/** the results are returned in an array */
|
|
55
|
+
inline?: number;
|
|
56
|
+
/**
|
|
57
|
+
* {replace: 'collectionName'} add the results to collectionName: the
|
|
58
|
+
* results replace the collection
|
|
59
|
+
*/
|
|
60
|
+
replace?: string;
|
|
61
|
+
/**
|
|
62
|
+
* {reduce: 'collectionName'} add the results to collectionName: if
|
|
63
|
+
* dups are detected, uses the reducer / finalize functions
|
|
64
|
+
*/
|
|
65
|
+
reduce?: string;
|
|
66
|
+
/**
|
|
67
|
+
* {merge: 'collectionName'} add the results to collectionName: if
|
|
68
|
+
* dups exist the new docs overwrite the old
|
|
69
|
+
*/
|
|
70
|
+
merge?: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface GeoSearchOptions {
|
|
75
|
+
/** x,y point to search for */
|
|
76
|
+
near: number[];
|
|
77
|
+
/** the maximum distance from the point near that a result can be */
|
|
78
|
+
maxDistance: number;
|
|
79
|
+
/** The maximum number of results to return */
|
|
80
|
+
limit?: number;
|
|
81
|
+
/** return the raw object instead of the Mongoose Model */
|
|
82
|
+
lean?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface ModifyResult<T> {
|
|
86
|
+
value: Require_id<T> | null;
|
|
87
|
+
/** see https://www.mongodb.com/docs/manual/reference/command/findAndModify/#lasterrorobject */
|
|
88
|
+
lastErrorObject?: {
|
|
89
|
+
updatedExisting?: boolean;
|
|
90
|
+
upserted?: mongodb.ObjectId;
|
|
91
|
+
};
|
|
92
|
+
ok: 0 | 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type WriteConcern = mongodb.WriteConcern;
|
|
96
|
+
|
|
97
|
+
/** A list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list. */
|
|
98
|
+
type PathsToValidate = string[] | string;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated
|
|
101
|
+
*/
|
|
102
|
+
type pathsToValidate = PathsToValidate;
|
|
103
|
+
|
|
104
|
+
interface SaveOptions extends
|
|
105
|
+
SessionOption {
|
|
106
|
+
checkKeys?: boolean;
|
|
107
|
+
j?: boolean;
|
|
108
|
+
safe?: boolean | WriteConcern;
|
|
109
|
+
timestamps?: boolean;
|
|
110
|
+
validateBeforeSave?: boolean;
|
|
111
|
+
validateModifiedOnly?: boolean;
|
|
112
|
+
w?: number | string;
|
|
113
|
+
wtimeout?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const Model: Model<any>;
|
|
117
|
+
interface Model<T, TQueryHelpers = {}, TMethodsAndOverrides = {}, TVirtuals = {}> extends
|
|
118
|
+
NodeJS.EventEmitter,
|
|
119
|
+
AcceptsDiscriminator,
|
|
120
|
+
IndexManager,
|
|
121
|
+
SessionStarter {
|
|
122
|
+
new <DocType = AnyKeys<T> & AnyObject>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
|
|
123
|
+
|
|
124
|
+
aggregate<R = any>(pipeline?: PipelineStage[], options?: mongodb.AggregateOptions, callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
125
|
+
aggregate<R = any>(pipeline: PipelineStage[], callback?: Callback<R[]>): Aggregate<Array<R>>;
|
|
126
|
+
|
|
127
|
+
/** Base Mongoose instance the model uses. */
|
|
128
|
+
base: Mongoose;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* If this is a discriminator model, `baseModelName` is the name of
|
|
132
|
+
* the base model.
|
|
133
|
+
*/
|
|
134
|
+
baseModelName: string | undefined;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Sends multiple `insertOne`, `updateOne`, `updateMany`, `replaceOne`,
|
|
138
|
+
* `deleteOne`, and/or `deleteMany` operations to the MongoDB server in one
|
|
139
|
+
* command. This is faster than sending multiple independent operations (e.g.
|
|
140
|
+
* if you use `create()`) because with `bulkWrite()` there is only one network
|
|
141
|
+
* round trip to the MongoDB server.
|
|
142
|
+
*/
|
|
143
|
+
bulkWrite(writes: Array<mongodb.AnyBulkWriteOperation>, options: mongodb.BulkWriteOptions & MongooseBulkWriteOptions, callback: Callback<mongodb.BulkWriteResult>): void;
|
|
144
|
+
bulkWrite(writes: Array<mongodb.AnyBulkWriteOperation>, callback: Callback<mongodb.BulkWriteResult>): void;
|
|
145
|
+
bulkWrite(writes: Array<mongodb.AnyBulkWriteOperation>, options?: mongodb.BulkWriteOptions & MongooseBulkWriteOptions): Promise<mongodb.BulkWriteResult>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Sends multiple `save()` calls in a single `bulkWrite()`. This is faster than
|
|
149
|
+
* sending multiple `save()` calls because with `bulkSave()` there is only one
|
|
150
|
+
* network round trip to the MongoDB server.
|
|
151
|
+
*/
|
|
152
|
+
bulkSave(documents: Array<Document>, options?: mongodb.BulkWriteOptions): Promise<mongodb.BulkWriteResult>;
|
|
153
|
+
|
|
154
|
+
/** Collection the model uses. */
|
|
155
|
+
collection: Collection;
|
|
156
|
+
|
|
157
|
+
/** Creates a `count` query: counts the number of documents that match `filter`. */
|
|
158
|
+
count(callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
159
|
+
count(filter: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
160
|
+
|
|
161
|
+
/** Creates a `countDocuments` query: counts the number of documents that match `filter`. */
|
|
162
|
+
countDocuments(filter: FilterQuery<T>, options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
163
|
+
countDocuments(callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
164
|
+
|
|
165
|
+
/** Creates a new document or documents */
|
|
166
|
+
create(docs: (AnyKeys<T> | AnyObject)[], options?: SaveOptions): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
167
|
+
create(docs: (AnyKeys<T> | AnyObject)[], callback: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>): void;
|
|
168
|
+
create(doc: AnyKeys<T> | AnyObject): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
169
|
+
create(doc: AnyKeys<T> | AnyObject, callback: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>): void;
|
|
170
|
+
create<DocContents = AnyKeys<T>>(docs: DocContents[], options?: SaveOptions): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
171
|
+
create<DocContents = AnyKeys<T>>(docs: DocContents[], callback: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>): void;
|
|
172
|
+
create<DocContents = AnyKeys<T>>(doc: DocContents): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
173
|
+
create<DocContents = AnyKeys<T>>(...docs: DocContents[]): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
174
|
+
create<DocContents = AnyKeys<T>>(doc: DocContents, callback: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>): void;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Create the collection for this model. By default, if no indexes are specified,
|
|
178
|
+
* mongoose will not create the collection for the model until any documents are
|
|
179
|
+
* created. Use this method to create the collection explicitly.
|
|
180
|
+
*/
|
|
181
|
+
createCollection<T extends mongodb.Document>(options: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'> | null, callback: Callback<mongodb.Collection<T>>): void;
|
|
182
|
+
createCollection<T extends mongodb.Document>(callback: Callback<mongodb.Collection<T>>): void;
|
|
183
|
+
createCollection<T extends mongodb.Document>(options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>): Promise<mongodb.Collection<T>>;
|
|
184
|
+
|
|
185
|
+
/** Connection the model uses. */
|
|
186
|
+
db: Connection;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Deletes all of the documents that match `conditions` from the collection.
|
|
190
|
+
* Behaves like `remove()`, but deletes all documents that match `conditions`
|
|
191
|
+
* regardless of the `single` option.
|
|
192
|
+
*/
|
|
193
|
+
deleteMany(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
194
|
+
deleteMany(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
195
|
+
deleteMany(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Deletes the first document that matches `conditions` from the collection.
|
|
199
|
+
* Behaves like `remove()`, but deletes at most one document regardless of the
|
|
200
|
+
* `single` option.
|
|
201
|
+
*/
|
|
202
|
+
deleteOne(filter?: FilterQuery<T>, options?: QueryOptions<T>, callback?: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
203
|
+
deleteOne(filter: FilterQuery<T>, callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
204
|
+
deleteOne(callback: CallbackWithoutResult): QueryWithHelpers<mongodb.DeleteResult, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Event emitter that reports any errors that occurred. Useful for global error
|
|
208
|
+
* handling.
|
|
209
|
+
*/
|
|
210
|
+
events: NodeJS.EventEmitter;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Finds a single document by its _id field. `findById(id)` is almost*
|
|
214
|
+
* equivalent to `findOne({ _id: id })`. If you want to query by a document's
|
|
215
|
+
* `_id`, use `findById()` instead of `findOne()`.
|
|
216
|
+
*/
|
|
217
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
218
|
+
id: any,
|
|
219
|
+
projection?: ProjectionType<T> | null,
|
|
220
|
+
options?: QueryOptions<T> | null,
|
|
221
|
+
callback?: Callback<ResultDoc | null>
|
|
222
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
223
|
+
findById<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
224
|
+
id: any,
|
|
225
|
+
projection?: ProjectionType<T> | null,
|
|
226
|
+
callback?: Callback<ResultDoc | null>
|
|
227
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
228
|
+
|
|
229
|
+
/** Finds one document. */
|
|
230
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
231
|
+
filter?: FilterQuery<T>,
|
|
232
|
+
projection?: ProjectionType<T> | null,
|
|
233
|
+
options?: QueryOptions<T> | null,
|
|
234
|
+
callback?: Callback<ResultDoc | null>
|
|
235
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
236
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
237
|
+
filter?: FilterQuery<T>,
|
|
238
|
+
projection?: ProjectionType<T> | null,
|
|
239
|
+
callback?: Callback<ResultDoc | null>
|
|
240
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
241
|
+
findOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
242
|
+
filter?: FilterQuery<T>,
|
|
243
|
+
callback?: Callback<ResultDoc | null>
|
|
244
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
|
|
248
|
+
* The document returned has no paths marked as modified initially.
|
|
249
|
+
*/
|
|
250
|
+
hydrate(obj: any): HydratedDocument<T, TMethodsAndOverrides, TVirtuals>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* This function is responsible for building [indexes](https://docs.mongodb.com/manual/indexes/),
|
|
254
|
+
* unless [`autoIndex`](http://mongoosejs.com/docs/guide.html#autoIndex) is turned off.
|
|
255
|
+
* Mongoose calls this function automatically when a model is created using
|
|
256
|
+
* [`mongoose.model()`](/docs/api.html#mongoose_Mongoose-model) or
|
|
257
|
+
* [`connection.model()`](/docs/api.html#connection_Connection-model), so you
|
|
258
|
+
* don't need to call it.
|
|
259
|
+
*/
|
|
260
|
+
init(callback?: CallbackWithoutResult): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
261
|
+
|
|
262
|
+
/** Inserts one or more new documents as a single `insertMany` call to the MongoDB server. */
|
|
263
|
+
insertMany(docs: Array<AnyKeys<T> | AnyObject>, options: InsertManyOptions & { rawResult: true }): Promise<InsertManyResult<T>>;
|
|
264
|
+
insertMany(docs: Array<AnyKeys<T> | AnyObject>, options?: InsertManyOptions): Promise<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>>;
|
|
265
|
+
insertMany(doc: AnyKeys<T> | AnyObject, options: InsertManyOptions & { rawResult: true }): Promise<InsertManyResult<T>>;
|
|
266
|
+
insertMany(doc: AnyKeys<T> | AnyObject, options?: InsertManyOptions): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[]>;
|
|
267
|
+
insertMany(doc: AnyKeys<T> | AnyObject, options?: InsertManyOptions, callback?: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>[] | InsertManyResult<T>>): void;
|
|
268
|
+
insertMany(docs: Array<AnyKeys<T> | AnyObject>, options?: InsertManyOptions, callback?: Callback<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>> | InsertManyResult<T>>): void;
|
|
269
|
+
|
|
270
|
+
/** The name of the model */
|
|
271
|
+
modelName: string;
|
|
272
|
+
|
|
273
|
+
/** Populates document references. */
|
|
274
|
+
populate(docs: Array<any>, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
275
|
+
callback?: Callback<(HydratedDocument<T, TMethodsAndOverrides, TVirtuals>)[]>): Promise<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>>;
|
|
276
|
+
populate(doc: any, options: PopulateOptions | Array<PopulateOptions> | string,
|
|
277
|
+
callback?: Callback<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>): Promise<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>;
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
/** Casts and validates the given object against this model's schema, passing the given `context` to custom validators. */
|
|
281
|
+
validate(callback?: CallbackWithoutResult): Promise<void>;
|
|
282
|
+
validate(optional: any, callback?: CallbackWithoutResult): Promise<void>;
|
|
283
|
+
validate(optional: any, pathsToValidate: PathsToValidate, callback?: CallbackWithoutResult): Promise<void>;
|
|
284
|
+
|
|
285
|
+
/** Watches the underlying collection for changes using [MongoDB change streams](https://docs.mongodb.com/manual/changeStreams/). */
|
|
286
|
+
watch<ResultType extends mongodb.Document = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions): mongodb.ChangeStream<ResultType>;
|
|
287
|
+
|
|
288
|
+
/** Adds a `$where` clause to this query */
|
|
289
|
+
$where(argument: string | Function): QueryWithHelpers<Array<HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
290
|
+
|
|
291
|
+
/** Registered discriminators for this model. */
|
|
292
|
+
discriminators: { [name: string]: Model<any> } | undefined;
|
|
293
|
+
|
|
294
|
+
/** Translate any aliases fields/conditions so the final query or document object is pure */
|
|
295
|
+
translateAliases(raw: any): any;
|
|
296
|
+
|
|
297
|
+
/** Creates a `distinct` query: returns the distinct values of the given `field` that match `filter`. */
|
|
298
|
+
distinct<ReturnType = any>(field: string, filter?: FilterQuery<T>, callback?: Callback<number>): QueryWithHelpers<Array<ReturnType>, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
299
|
+
|
|
300
|
+
/** Creates a `estimatedDocumentCount` query: counts the number of documents in the collection. */
|
|
301
|
+
estimatedDocumentCount(options?: QueryOptions<T>, callback?: Callback<number>): QueryWithHelpers<number, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Returns a document with its `_id` if at least one document exists in the database that matches
|
|
305
|
+
* the given `filter`, and `null` otherwise.
|
|
306
|
+
*/
|
|
307
|
+
exists(filter: FilterQuery<T>, callback: Callback<Pick<Document<T>, '_id'> | null>): QueryWithHelpers<Pick<Document<T>, '_id'> | null, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
308
|
+
exists(filter: FilterQuery<T>): QueryWithHelpers<Pick<Document<T>, '_id'> | null, HydratedDocument<T, TMethodsAndOverrides, TVirtuals>, TQueryHelpers, T>;
|
|
309
|
+
|
|
310
|
+
/** Creates a `find` query: gets a list of documents that match `filter`. */
|
|
311
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
312
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
313
|
+
filter: FilterQuery<T>,
|
|
314
|
+
projection?: ProjectionType<T> | null,
|
|
315
|
+
callback?: Callback<ResultDoc[]>
|
|
316
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
317
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
318
|
+
find<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, projection?: ProjectionType<T> | null, options?: QueryOptions<T> | null, callback?: Callback<ResultDoc[]>): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
319
|
+
|
|
320
|
+
/** Creates a `findByIdAndDelete` query, filtering by the given `_id`. */
|
|
321
|
+
findByIdAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
322
|
+
|
|
323
|
+
/** Creates a `findByIdAndRemove` query, filtering by the given `_id`. */
|
|
324
|
+
findByIdAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
325
|
+
|
|
326
|
+
/** Creates a `findOneAndUpdate` query, filtering by the given `_id`. */
|
|
327
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { rawResult: true }, callback?: (err: CallbackError, doc: any, res: any) => void): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
328
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
329
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id?: mongodb.ObjectId | any, update?: UpdateQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
330
|
+
findByIdAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(id: mongodb.ObjectId | any, update: UpdateQuery<T>, callback: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
331
|
+
|
|
332
|
+
/** Creates a `findOneAndDelete` query: atomically finds the given document, deletes it, and returns the document as it was before deletion. */
|
|
333
|
+
findOneAndDelete<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
334
|
+
|
|
335
|
+
/** Creates a `findOneAndRemove` query: atomically finds the given document and deletes it. */
|
|
336
|
+
findOneAndRemove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
337
|
+
|
|
338
|
+
/** Creates a `findOneAndReplace` query: atomically finds the given document and replaces it with `replacement`. */
|
|
339
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter: FilterQuery<T>, replacement: T | AnyObject, options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc, callback?: (err: CallbackError, doc: ResultDoc, res: any) => void): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
340
|
+
findOneAndReplace<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: FilterQuery<T>, replacement?: T | AnyObject, options?: QueryOptions<T> | null, callback?: (err: CallbackError, doc: ResultDoc | null, res: any) => void): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
341
|
+
|
|
342
|
+
/** Creates a `findOneAndUpdate` query: atomically find the first document that matches `filter` and apply `update`. */
|
|
343
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
344
|
+
filter: FilterQuery<T>,
|
|
345
|
+
update: UpdateQuery<T>,
|
|
346
|
+
options: QueryOptions<T> & { rawResult: true },
|
|
347
|
+
callback?: (err: CallbackError, doc: any, res: any) => void
|
|
348
|
+
): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
349
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
350
|
+
filter: FilterQuery<T>,
|
|
351
|
+
update: UpdateQuery<T>,
|
|
352
|
+
options: QueryOptions<T> & { upsert: true } & ReturnsNewDoc,
|
|
353
|
+
callback?: (err: CallbackError, doc: ResultDoc, res: any) => void
|
|
354
|
+
): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, T>;
|
|
355
|
+
findOneAndUpdate<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
356
|
+
filter?: FilterQuery<T>,
|
|
357
|
+
update?: UpdateQuery<T>,
|
|
358
|
+
options?: QueryOptions<T> | null,
|
|
359
|
+
callback?: (err: CallbackError, doc: T | null, res: any) => void
|
|
360
|
+
): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, T>;
|
|
361
|
+
|
|
362
|
+
geoSearch<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
363
|
+
filter?: FilterQuery<T>,
|
|
364
|
+
options?: GeoSearchOptions,
|
|
365
|
+
callback?: Callback<Array<ResultDoc>>
|
|
366
|
+
): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
367
|
+
|
|
368
|
+
/** Executes a mapReduce command. */
|
|
369
|
+
mapReduce<Key, Value>(
|
|
370
|
+
o: MapReduceOptions<T, Key, Value>,
|
|
371
|
+
callback?: Callback
|
|
372
|
+
): Promise<any>;
|
|
373
|
+
|
|
374
|
+
remove<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(filter?: any, callback?: CallbackWithoutResult): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
375
|
+
|
|
376
|
+
/** Creates a `replaceOne` query: finds the first document that matches `filter` and replaces it with `replacement`. */
|
|
377
|
+
replaceOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
378
|
+
filter?: FilterQuery<T>,
|
|
379
|
+
replacement?: T | AnyObject,
|
|
380
|
+
options?: QueryOptions<T> | null,
|
|
381
|
+
callback?: Callback
|
|
382
|
+
): QueryWithHelpers<any, ResultDoc, TQueryHelpers, T>;
|
|
383
|
+
|
|
384
|
+
/** Schema the model uses. */
|
|
385
|
+
schema: Schema<T>;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* @deprecated use `updateOne` or `updateMany` instead.
|
|
389
|
+
* Creates a `update` query: updates one or many documents that match `filter` with `update`, based on the `multi` option.
|
|
390
|
+
*/
|
|
391
|
+
update<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
392
|
+
filter?: FilterQuery<T>,
|
|
393
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
394
|
+
options?: QueryOptions<T> | null,
|
|
395
|
+
callback?: Callback
|
|
396
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
397
|
+
|
|
398
|
+
/** Creates a `updateMany` query: updates all documents that match `filter` with `update`. */
|
|
399
|
+
updateMany<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
400
|
+
filter?: FilterQuery<T>,
|
|
401
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
402
|
+
options?: QueryOptions<T> | null,
|
|
403
|
+
callback?: Callback
|
|
404
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
405
|
+
|
|
406
|
+
/** Creates a `updateOne` query: updates the first document that matches `filter` with `update`. */
|
|
407
|
+
updateOne<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(
|
|
408
|
+
filter?: FilterQuery<T>,
|
|
409
|
+
update?: UpdateQuery<T> | UpdateWithAggregationPipeline,
|
|
410
|
+
options?: QueryOptions<T> | null,
|
|
411
|
+
callback?: Callback
|
|
412
|
+
): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, T>;
|
|
413
|
+
|
|
414
|
+
/** Creates a Query, applies the passed conditions, and returns the Query. */
|
|
415
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(path: string, val?: any): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
416
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(obj: object): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
417
|
+
where<ResultDoc = HydratedDocument<T, TMethodsAndOverrides, TVirtuals>>(): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, T>;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare module 'mongoose' {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reference another Model
|
|
5
|
+
*/
|
|
6
|
+
type PopulatedDoc<
|
|
7
|
+
PopulatedType,
|
|
8
|
+
RawId extends RefType = (PopulatedType extends { _id?: RefType; } ? NonNullable<PopulatedType['_id']> : Types.ObjectId) | undefined
|
|
9
|
+
> = PopulatedType | RawId;
|
|
10
|
+
|
|
11
|
+
interface PopulateOptions {
|
|
12
|
+
/** space delimited path(s) to populate */
|
|
13
|
+
path: string;
|
|
14
|
+
/** fields to select */
|
|
15
|
+
select?: any;
|
|
16
|
+
/** query conditions to match */
|
|
17
|
+
match?: any;
|
|
18
|
+
/** optional model to use for population */
|
|
19
|
+
model?: string | Model<any>;
|
|
20
|
+
/** optional query options like sort, limit, etc */
|
|
21
|
+
options?: QueryOptions;
|
|
22
|
+
/** correct limit on populated array */
|
|
23
|
+
perDocumentLimit?: number;
|
|
24
|
+
/** optional boolean, set to `false` to allow populating paths that aren't in the schema */
|
|
25
|
+
strictPopulate?: boolean;
|
|
26
|
+
/** deep populate */
|
|
27
|
+
populate?: string | PopulateOptions | (string | PopulateOptions)[];
|
|
28
|
+
/**
|
|
29
|
+
* If true Mongoose will always set `path` to an array, if false Mongoose will
|
|
30
|
+
* always set `path` to a document. Inferred from schema by default.
|
|
31
|
+
*/
|
|
32
|
+
justOne?: boolean;
|
|
33
|
+
/** transform function to call on every populated doc */
|
|
34
|
+
transform?: (doc: any, id: any) => any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface PopulateOption {
|
|
38
|
+
populate?: string | string[] | PopulateOptions | PopulateOptions[];
|
|
39
|
+
}
|
|
40
|
+
}
|