1 | declare module 'mongoose' {
|
2 | import mongodb = require('mongodb');
|
3 |
|
4 | export interface DiscriminatorOptions {
|
5 | value?: string | number | ObjectId;
|
6 | clone?: boolean;
|
7 | overwriteModels?: boolean;
|
8 | mergeHooks?: boolean;
|
9 | mergePlugins?: boolean;
|
10 | }
|
11 |
|
12 | export interface AcceptsDiscriminator {
|
13 |
|
14 | discriminator<D>(
|
15 | name: string | number,
|
16 | schema: Schema,
|
17 | value?: string | number | ObjectId | DiscriminatorOptions
|
18 | ): Model<D>;
|
19 | discriminator<T, U>(
|
20 | name: string | number,
|
21 | schema: Schema<T, U>,
|
22 | value?: string | number | ObjectId | DiscriminatorOptions
|
23 | ): U;
|
24 | }
|
25 |
|
26 | interface MongooseBulkWriteOptions extends mongodb.BulkWriteOptions {
|
27 | session?: ClientSession;
|
28 | skipValidation?: boolean;
|
29 | throwOnValidationError?: boolean;
|
30 | strict?: boolean | 'throw';
|
31 |
|
32 | timestamps?: boolean;
|
33 | }
|
34 |
|
35 | interface MongooseBulkSaveOptions extends mongodb.BulkWriteOptions {
|
36 | timestamps?: boolean;
|
37 | session?: ClientSession;
|
38 | }
|
39 |
|
40 | |
41 |
|
42 |
|
43 | interface MongooseBulkWritePerWriteOptions {
|
44 | timestamps?: boolean;
|
45 | strict?: boolean | 'throw';
|
46 | session?: ClientSession;
|
47 | skipValidation?: boolean;
|
48 | }
|
49 |
|
50 | interface HydrateOptions {
|
51 | setters?: boolean;
|
52 | hydratedPopulatedDocs?: boolean;
|
53 | }
|
54 |
|
55 | interface InsertManyOptions extends
|
56 | PopulateOption,
|
57 | SessionOption {
|
58 | limit?: number;
|
59 |
|
60 | rawResult?: boolean;
|
61 | includeResultMetadata?: boolean;
|
62 | ordered?: boolean;
|
63 | lean?: boolean;
|
64 | throwOnValidationError?: boolean;
|
65 | }
|
66 |
|
67 | type InsertManyResult<T> = mongodb.InsertManyResult<T> & {
|
68 | insertedIds: {
|
69 | [key: number]: InferId<T>;
|
70 | };
|
71 | mongoose?: { validationErrors?: Array<Error.CastError | Error.ValidatorError> };
|
72 | };
|
73 |
|
74 | type UpdateWriteOpResult = mongodb.UpdateResult;
|
75 |
|
76 | interface MapReduceOptions<T, K, R> {
|
77 | map: Function | string;
|
78 | reduce: (key: K, vals: T[]) => R;
|
79 |
|
80 | query?: any;
|
81 |
|
82 | sort?: any;
|
83 |
|
84 | limit?: number;
|
85 |
|
86 | keeptemp?: boolean;
|
87 |
|
88 | finalize?: (key: K, val: R) => R;
|
89 |
|
90 | scope?: any;
|
91 |
|
92 | jsMode?: boolean;
|
93 |
|
94 | verbose?: boolean;
|
95 | readPreference?: string;
|
96 |
|
97 | out?: {
|
98 |
|
99 | inline?: number;
|
100 | |
101 |
|
102 |
|
103 |
|
104 | replace?: string;
|
105 | |
106 |
|
107 |
|
108 |
|
109 | reduce?: string;
|
110 | |
111 |
|
112 |
|
113 |
|
114 | merge?: string;
|
115 | };
|
116 | }
|
117 |
|
118 | interface GeoSearchOptions {
|
119 |
|
120 | near: number[];
|
121 |
|
122 | maxDistance: number;
|
123 |
|
124 | limit?: number;
|
125 |
|
126 | lean?: boolean;
|
127 | }
|
128 |
|
129 | interface ModifyResult<T> {
|
130 | value: Require_id<T> | null;
|
131 |
|
132 | lastErrorObject?: {
|
133 | updatedExisting?: boolean;
|
134 | upserted?: mongodb.ObjectId;
|
135 | };
|
136 | ok: 0 | 1;
|
137 | }
|
138 |
|
139 | type WriteConcern = mongodb.WriteConcern;
|
140 |
|
141 |
|
142 | type PathsToValidate = string[] | string;
|
143 | |
144 |
|
145 |
|
146 | type pathsToValidate = PathsToValidate;
|
147 |
|
148 | interface SaveOptions extends
|
149 | SessionOption {
|
150 | checkKeys?: boolean;
|
151 | j?: boolean;
|
152 | safe?: boolean | WriteConcern;
|
153 | timestamps?: boolean | QueryTimestampsConfig;
|
154 | validateBeforeSave?: boolean;
|
155 | validateModifiedOnly?: boolean;
|
156 | w?: number | string;
|
157 | wtimeout?: number;
|
158 | }
|
159 |
|
160 | interface CreateOptions extends SaveOptions {
|
161 | ordered?: boolean;
|
162 | aggregateErrors?: boolean;
|
163 | }
|
164 |
|
165 | interface RemoveOptions extends SessionOption, Omit<mongodb.DeleteOptions, 'session'> {}
|
166 |
|
167 | const Model: Model<any>;
|
168 |
|
169 | export type AnyBulkWriteOperation<TSchema = AnyObject> = {
|
170 | insertOne: InsertOneModel<TSchema>;
|
171 | } | {
|
172 | replaceOne: ReplaceOneModel<TSchema>;
|
173 | } | {
|
174 | updateOne: UpdateOneModel<TSchema>;
|
175 | } | {
|
176 | updateMany: UpdateManyModel<TSchema>;
|
177 | } | {
|
178 | deleteOne: DeleteOneModel<TSchema>;
|
179 | } | {
|
180 | deleteMany: DeleteManyModel<TSchema>;
|
181 | };
|
182 |
|
183 | export interface InsertOneModel<TSchema> {
|
184 | document: mongodb.OptionalId<TSchema>;
|
185 |
|
186 | timestamps?: boolean;
|
187 | }
|
188 |
|
189 | export interface ReplaceOneModel<TSchema = AnyObject> {
|
190 |
|
191 | filter: FilterQuery<TSchema>;
|
192 |
|
193 | replacement: mongodb.WithoutId<TSchema>;
|
194 |
|
195 | collation?: mongodb.CollationOptions;
|
196 |
|
197 | hint?: mongodb.Hint;
|
198 |
|
199 | upsert?: boolean;
|
200 |
|
201 | timestamps?: boolean;
|
202 | }
|
203 |
|
204 | export interface UpdateOneModel<TSchema = AnyObject> {
|
205 |
|
206 | filter: FilterQuery<TSchema>;
|
207 |
|
208 | update: UpdateQuery<TSchema>;
|
209 |
|
210 | arrayFilters?: AnyObject[];
|
211 |
|
212 | collation?: mongodb.CollationOptions;
|
213 |
|
214 | hint?: mongodb.Hint;
|
215 |
|
216 | upsert?: boolean;
|
217 |
|
218 | timestamps?: boolean;
|
219 | }
|
220 |
|
221 | export interface UpdateManyModel<TSchema = AnyObject> {
|
222 |
|
223 | filter: FilterQuery<TSchema>;
|
224 |
|
225 | update: UpdateQuery<TSchema>;
|
226 |
|
227 | arrayFilters?: AnyObject[];
|
228 |
|
229 | collation?: mongodb.CollationOptions;
|
230 |
|
231 | hint?: mongodb.Hint;
|
232 |
|
233 | upsert?: boolean;
|
234 |
|
235 | timestamps?: boolean;
|
236 | }
|
237 |
|
238 | export interface DeleteOneModel<TSchema = AnyObject> {
|
239 |
|
240 | filter: FilterQuery<TSchema>;
|
241 |
|
242 | collation?: mongodb.CollationOptions;
|
243 |
|
244 | hint?: mongodb.Hint;
|
245 | }
|
246 |
|
247 | export interface DeleteManyModel<TSchema = AnyObject> {
|
248 |
|
249 | filter: FilterQuery<TSchema>;
|
250 |
|
251 | collation?: mongodb.CollationOptions;
|
252 |
|
253 | hint?: mongodb.Hint;
|
254 | }
|
255 |
|
256 | |
257 |
|
258 |
|
259 |
|
260 |
|
261 | export interface Model<
|
262 | TRawDocType,
|
263 | TQueryHelpers = {},
|
264 | TInstanceMethods = {},
|
265 | TVirtuals = {},
|
266 | THydratedDocumentType = HydratedDocument<TRawDocType, TVirtuals & TInstanceMethods, TQueryHelpers>,
|
267 | TSchema = any> extends
|
268 | NodeJS.EventEmitter,
|
269 | AcceptsDiscriminator,
|
270 | IndexManager,
|
271 | SessionStarter {
|
272 | new <DocType = Partial<TRawDocType>>(doc?: DocType, fields?: any | null, options?: boolean | AnyObject): THydratedDocumentType;
|
273 |
|
274 | aggregate<R = any>(pipeline?: PipelineStage[], options?: AggregateOptions): Aggregate<Array<R>>;
|
275 | aggregate<R = any>(pipeline: PipelineStage[]): Aggregate<Array<R>>;
|
276 |
|
277 |
|
278 | base: Mongoose;
|
279 |
|
280 | |
281 |
|
282 |
|
283 |
|
284 | baseModelName: string | undefined;
|
285 |
|
286 |
|
287 | castObject(obj: AnyObject, options?: { ignoreCastErrors?: boolean }): TRawDocType;
|
288 |
|
289 |
|
290 | applyDefaults(obj: AnyObject): AnyObject;
|
291 | applyDefaults(obj: TRawDocType): TRawDocType;
|
292 |
|
293 | |
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | bulkWrite<DocContents = TRawDocType>(
|
301 | writes: Array<AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
302 | options: MongooseBulkWriteOptions & { ordered: false }
|
303 | ): Promise<mongodb.BulkWriteResult & { mongoose?: { validationErrors: Error[] } }>;
|
304 | bulkWrite<DocContents = TRawDocType>(
|
305 | writes: Array<AnyBulkWriteOperation<DocContents extends Document ? any : (DocContents extends {} ? DocContents : any)>>,
|
306 | options?: MongooseBulkWriteOptions
|
307 | ): Promise<mongodb.BulkWriteResult>;
|
308 |
|
309 | |
310 |
|
311 |
|
312 |
|
313 |
|
314 | bulkSave(documents: Array<Document>, options?: MongooseBulkSaveOptions): Promise<mongodb.BulkWriteResult>;
|
315 |
|
316 |
|
317 | collection: Collection;
|
318 |
|
319 |
|
320 | countDocuments(
|
321 | filter?: FilterQuery<TRawDocType>,
|
322 | options?: (mongodb.CountOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
323 | ): QueryWithHelpers<
|
324 | number,
|
325 | THydratedDocumentType,
|
326 | TQueryHelpers,
|
327 | TRawDocType,
|
328 | 'countDocuments',
|
329 | TInstanceMethods
|
330 | >;
|
331 |
|
332 |
|
333 | create<DocContents = AnyKeys<TRawDocType>>(docs: Array<TRawDocType | DocContents>, options: CreateOptions & { aggregateErrors: true }): Promise<(THydratedDocumentType | Error)[]>;
|
334 | create<DocContents = AnyKeys<TRawDocType>>(docs: Array<TRawDocType | DocContents>, options?: CreateOptions): Promise<THydratedDocumentType[]>;
|
335 | create<DocContents = AnyKeys<TRawDocType>>(doc: DocContents | TRawDocType): Promise<THydratedDocumentType>;
|
336 | create<DocContents = AnyKeys<TRawDocType>>(...docs: Array<TRawDocType | DocContents>): Promise<THydratedDocumentType[]>;
|
337 |
|
338 | |
339 |
|
340 |
|
341 |
|
342 |
|
343 | createCollection<T extends mongodb.Document>(options?: mongodb.CreateCollectionOptions & Pick<SchemaOptions, 'expires'>): Promise<mongodb.Collection<T>>;
|
344 |
|
345 | |
346 |
|
347 |
|
348 |
|
349 | createSearchIndex(description: SearchIndexDescription): Promise<string>;
|
350 |
|
351 |
|
352 | db: Connection;
|
353 |
|
354 | |
355 |
|
356 |
|
357 |
|
358 |
|
359 | deleteMany(
|
360 | filter?: FilterQuery<TRawDocType>,
|
361 | options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
362 | ): QueryWithHelpers<
|
363 | mongodb.DeleteResult,
|
364 | THydratedDocumentType,
|
365 | TQueryHelpers,
|
366 | TRawDocType,
|
367 | 'deleteMany',
|
368 | TInstanceMethods
|
369 | >;
|
370 | deleteMany(
|
371 | filter: FilterQuery<TRawDocType>
|
372 | ): QueryWithHelpers<
|
373 | mongodb.DeleteResult,
|
374 | THydratedDocumentType,
|
375 | TQueryHelpers,
|
376 | TRawDocType,
|
377 | 'deleteMany',
|
378 | TInstanceMethods
|
379 | >;
|
380 |
|
381 | |
382 |
|
383 |
|
384 |
|
385 |
|
386 | deleteOne(
|
387 | filter?: FilterQuery<TRawDocType>,
|
388 | options?: (mongodb.DeleteOptions & MongooseBaseQueryOptions<TRawDocType>) | null
|
389 | ): QueryWithHelpers<
|
390 | mongodb.DeleteResult,
|
391 | THydratedDocumentType,
|
392 | TQueryHelpers,
|
393 | TRawDocType,
|
394 | 'deleteOne',
|
395 | TInstanceMethods
|
396 | >;
|
397 | deleteOne(
|
398 | filter: FilterQuery<TRawDocType>
|
399 | ): QueryWithHelpers<
|
400 | mongodb.DeleteResult,
|
401 | THydratedDocumentType,
|
402 | TQueryHelpers,
|
403 | TRawDocType,
|
404 | 'deleteOne',
|
405 | TInstanceMethods
|
406 | >;
|
407 |
|
408 | |
409 |
|
410 |
|
411 |
|
412 | dropSearchIndex(name: string): Promise<void>;
|
413 |
|
414 | |
415 |
|
416 |
|
417 |
|
418 | events: NodeJS.EventEmitter;
|
419 |
|
420 | |
421 |
|
422 |
|
423 |
|
424 |
|
425 | findById<ResultDoc = THydratedDocumentType>(
|
426 | id: any,
|
427 | projection: ProjectionType<TRawDocType> | null | undefined,
|
428 | options: QueryOptions<TRawDocType> & { lean: true }
|
429 | ): QueryWithHelpers<
|
430 | GetLeanResultType<TRawDocType, TRawDocType, 'findOne'> | null,
|
431 | ResultDoc,
|
432 | TQueryHelpers,
|
433 | TRawDocType,
|
434 | 'findOne',
|
435 | TInstanceMethods
|
436 | >;
|
437 | findById<ResultDoc = THydratedDocumentType>(
|
438 | id: any,
|
439 | projection?: ProjectionType<TRawDocType> | null,
|
440 | options?: QueryOptions<TRawDocType> | null
|
441 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
442 | findById<ResultDoc = THydratedDocumentType>(
|
443 | id: any,
|
444 | projection?: ProjectionType<TRawDocType> | null
|
445 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
446 |
|
447 |
|
448 | findOne<ResultDoc = THydratedDocumentType>(
|
449 | filter: FilterQuery<TRawDocType>,
|
450 | projection: ProjectionType<TRawDocType> | null | undefined,
|
451 | options: QueryOptions<TRawDocType> & { lean: true }
|
452 | ): QueryWithHelpers<
|
453 | GetLeanResultType<TRawDocType, TRawDocType, 'findOne'> | null,
|
454 | ResultDoc,
|
455 | TQueryHelpers,
|
456 | TRawDocType,
|
457 | 'findOne',
|
458 | TInstanceMethods
|
459 | >;
|
460 | findOne<ResultDoc = THydratedDocumentType>(
|
461 | filter?: FilterQuery<TRawDocType>,
|
462 | projection?: ProjectionType<TRawDocType> | null,
|
463 | options?: QueryOptions<TRawDocType> | null
|
464 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
465 | findOne<ResultDoc = THydratedDocumentType>(
|
466 | filter?: FilterQuery<TRawDocType>,
|
467 | projection?: ProjectionType<TRawDocType> | null
|
468 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
469 | findOne<ResultDoc = THydratedDocumentType>(
|
470 | filter?: FilterQuery<TRawDocType>
|
471 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOne', TInstanceMethods>;
|
472 |
|
473 | |
474 |
|
475 |
|
476 |
|
477 | hydrate(obj: any, projection?: AnyObject, options?: HydrateOptions): THydratedDocumentType;
|
478 |
|
479 | |
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 | init(): Promise<THydratedDocumentType>;
|
488 |
|
489 |
|
490 | insertMany(
|
491 | docs: Array<TRawDocType>
|
492 | ): Promise<Array<THydratedDocumentType>>;
|
493 | insertMany(
|
494 | docs: Array<TRawDocType>,
|
495 | options: InsertManyOptions & { lean: true; }
|
496 | ): Promise<Array<Require_id<TRawDocType>>>;
|
497 | insertMany(
|
498 | doc: Array<TRawDocType>,
|
499 | options: InsertManyOptions & { ordered: false; rawResult: true; }
|
500 | ): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>> & {
|
501 | mongoose: {
|
502 | validationErrors: (CastError | Error.ValidatorError)[];
|
503 | results: Array<
|
504 | Error |
|
505 | Object |
|
506 | THydratedDocumentType
|
507 | >
|
508 | }
|
509 | }>;
|
510 | insertMany(
|
511 | docs: Array<TRawDocType>,
|
512 | options: InsertManyOptions & { lean: true, rawResult: true; }
|
513 | ): Promise<mongodb.InsertManyResult<Require_id<TRawDocType>>>;
|
514 | insertMany(
|
515 | docs: Array<TRawDocType>,
|
516 | options: InsertManyOptions & { rawResult: true; }
|
517 | ): Promise<mongodb.InsertManyResult<Require_id<THydratedDocumentType>>>;
|
518 | insertMany(
|
519 | doc: Array<TRawDocType>,
|
520 | options: InsertManyOptions
|
521 | ): Promise<Array<THydratedDocumentType>>;
|
522 | insertMany<DocContents = TRawDocType>(
|
523 | docs: Array<DocContents | TRawDocType>,
|
524 | options: InsertManyOptions & { lean: true; }
|
525 | ): Promise<Array<Require_id<DocContents>>>;
|
526 | insertMany<DocContents = TRawDocType>(
|
527 | docs: DocContents | TRawDocType,
|
528 | options: InsertManyOptions & { lean: true; }
|
529 | ): Promise<Array<Require_id<DocContents>>>;
|
530 | insertMany<DocContents = TRawDocType>(
|
531 | doc: DocContents | TRawDocType,
|
532 | options: InsertManyOptions & { ordered: false; rawResult: true; }
|
533 | ): Promise<mongodb.InsertManyResult<Require_id<DocContents>> & {
|
534 | mongoose: {
|
535 | validationErrors: (CastError | Error.ValidatorError)[];
|
536 | results: Array<
|
537 | Error |
|
538 | Object |
|
539 | MergeType<THydratedDocumentType, DocContents>
|
540 | >
|
541 | }
|
542 | }>;
|
543 | insertMany<DocContents = TRawDocType>(
|
544 | docs: Array<DocContents | TRawDocType>,
|
545 | options: InsertManyOptions & { rawResult: true; }
|
546 | ): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>;
|
547 | insertMany<DocContents = TRawDocType>(
|
548 | docs: Array<DocContents | TRawDocType>
|
549 | ): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
550 | insertMany<DocContents = TRawDocType>(
|
551 | doc: DocContents,
|
552 | options: InsertManyOptions & { lean: true; }
|
553 | ): Promise<Array<Require_id<DocContents>>>;
|
554 | insertMany<DocContents = TRawDocType>(
|
555 | doc: DocContents,
|
556 | options: InsertManyOptions & { rawResult: true; }
|
557 | ): Promise<mongodb.InsertManyResult<Require_id<DocContents>>>;
|
558 | insertMany<DocContents = TRawDocType>(
|
559 | doc: DocContents,
|
560 | options: InsertManyOptions
|
561 | ): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
562 | insertMany<DocContents = TRawDocType>(
|
563 | docs: Array<DocContents | TRawDocType>,
|
564 | options: InsertManyOptions
|
565 | ): Promise<Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>>;
|
566 | insertMany<DocContents = TRawDocType>(
|
567 | doc: DocContents
|
568 | ): Promise<
|
569 | Array<MergeType<THydratedDocumentType, Omit<DocContents, '_id'>>>
|
570 | >;
|
571 |
|
572 | |
573 |
|
574 |
|
575 |
|
576 | listSearchIndexes(options?: mongodb.ListSearchIndexesOptions): Promise<Array<{ name: string }>>;
|
577 |
|
578 |
|
579 | modelName: string;
|
580 |
|
581 |
|
582 | populate(
|
583 | docs: Array<any>,
|
584 | options: PopulateOptions | Array<PopulateOptions> | string
|
585 | ): Promise<Array<THydratedDocumentType>>;
|
586 | populate(
|
587 | doc: any, options: PopulateOptions | Array<PopulateOptions> | string
|
588 | ): Promise<THydratedDocumentType>;
|
589 | populate<Paths>(
|
590 | docs: Array<any>,
|
591 | options: PopulateOptions | Array<PopulateOptions> | string
|
592 | ): Promise<Array<MergeType<THydratedDocumentType, Paths>>>;
|
593 | populate<Paths>(
|
594 | doc: any, options: PopulateOptions | Array<PopulateOptions> | string
|
595 | ): Promise<MergeType<THydratedDocumentType, Paths>>;
|
596 |
|
597 | |
598 |
|
599 |
|
600 |
|
601 | updateSearchIndex(name: string, definition: AnyObject): Promise<void>;
|
602 |
|
603 |
|
604 | validate(): Promise<void>;
|
605 | validate(obj: any): Promise<void>;
|
606 | validate(obj: any, pathsOrOptions: PathsToValidate): Promise<void>;
|
607 | validate(obj: any, pathsOrOptions: { pathsToSkip?: pathsToSkip }): Promise<void>;
|
608 |
|
609 |
|
610 | watch<ResultType extends mongodb.Document = any, ChangeType extends mongodb.ChangeStreamDocument = any>(pipeline?: Array<Record<string, unknown>>, options?: mongodb.ChangeStreamOptions & { hydrate?: boolean }): mongodb.ChangeStream<ResultType, ChangeType>;
|
611 |
|
612 |
|
613 | $where(argument: string | Function): QueryWithHelpers<Array<THydratedDocumentType>, THydratedDocumentType, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
614 |
|
615 |
|
616 | discriminators: { [name: string]: Model<any> } | undefined;
|
617 |
|
618 |
|
619 | translateAliases(raw: any): any;
|
620 |
|
621 |
|
622 | distinct<DocKey extends string, ResultType = unknown>(
|
623 | field: DocKey,
|
624 | filter?: FilterQuery<TRawDocType>
|
625 | ): QueryWithHelpers<
|
626 | Array<
|
627 | DocKey extends keyof WithLevel1NestedPaths<TRawDocType>
|
628 | ? WithoutUndefined<Unpacked<WithLevel1NestedPaths<TRawDocType>[DocKey]>>
|
629 | : ResultType
|
630 | >,
|
631 | THydratedDocumentType,
|
632 | TQueryHelpers,
|
633 | TRawDocType,
|
634 | 'distinct',
|
635 | TInstanceMethods
|
636 | >;
|
637 |
|
638 |
|
639 | estimatedDocumentCount(options?: QueryOptions<TRawDocType>): QueryWithHelpers<
|
640 | number,
|
641 | THydratedDocumentType,
|
642 | TQueryHelpers,
|
643 | TRawDocType,
|
644 | 'estimatedDocumentCount',
|
645 | TInstanceMethods
|
646 | >;
|
647 |
|
648 | |
649 |
|
650 |
|
651 |
|
652 | exists(
|
653 | filter: FilterQuery<TRawDocType>
|
654 | ): QueryWithHelpers<
|
655 | { _id: InferId<TRawDocType> } | null,
|
656 | THydratedDocumentType,
|
657 | TQueryHelpers,
|
658 | TRawDocType,
|
659 | 'findOne',
|
660 | TInstanceMethods
|
661 | >;
|
662 |
|
663 |
|
664 | find<ResultDoc = THydratedDocumentType>(
|
665 | filter: FilterQuery<TRawDocType>,
|
666 | projection: ProjectionType<TRawDocType> | null | undefined,
|
667 | options: QueryOptions<TRawDocType> & { lean: true }
|
668 | ): QueryWithHelpers<
|
669 | GetLeanResultType<TRawDocType, TRawDocType[], 'find'>,
|
670 | ResultDoc,
|
671 | TQueryHelpers,
|
672 | TRawDocType,
|
673 | 'find',
|
674 | TInstanceMethods
|
675 | >;
|
676 | find<ResultDoc = THydratedDocumentType>(
|
677 | filter: FilterQuery<TRawDocType>,
|
678 | projection?: ProjectionType<TRawDocType> | null | undefined,
|
679 | options?: QueryOptions<TRawDocType> | null | undefined
|
680 | ): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
681 | find<ResultDoc = THydratedDocumentType>(
|
682 | filter: FilterQuery<TRawDocType>,
|
683 | projection?: ProjectionType<TRawDocType> | null | undefined
|
684 | ): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
685 | find<ResultDoc = THydratedDocumentType>(
|
686 | filter: FilterQuery<TRawDocType>
|
687 | ): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
688 | find<ResultDoc = THydratedDocumentType>(
|
689 | ): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
690 |
|
691 |
|
692 | findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
693 | id: mongodb.ObjectId | any,
|
694 | options: QueryOptions<TRawDocType> & { lean: true }
|
695 | ): QueryWithHelpers<
|
696 | GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndDelete'> | null,
|
697 | ResultDoc,
|
698 | TQueryHelpers,
|
699 | TRawDocType,
|
700 | 'findOneAndDelete',
|
701 | TInstanceMethods
|
702 | >;
|
703 | findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
704 | id: mongodb.ObjectId | any,
|
705 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
706 | ): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
707 | findByIdAndDelete<ResultDoc = THydratedDocumentType>(
|
708 | id?: mongodb.ObjectId | any,
|
709 | options?: QueryOptions<TRawDocType> | null
|
710 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
711 |
|
712 |
|
713 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
714 | filter: FilterQuery<TRawDocType>,
|
715 | update: UpdateQuery<TRawDocType>,
|
716 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
717 | ): QueryWithHelpers<
|
718 | ModifyResult<TRawDocType>,
|
719 | ResultDoc,
|
720 | TQueryHelpers,
|
721 | TRawDocType,
|
722 | 'findOneAndUpdate',
|
723 | TInstanceMethods
|
724 | >;
|
725 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
726 | id: mongodb.ObjectId | any,
|
727 | update: UpdateQuery<TRawDocType>,
|
728 | options: QueryOptions<TRawDocType> & { lean: true }
|
729 | ): QueryWithHelpers<
|
730 | GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
|
731 | ResultDoc,
|
732 | TQueryHelpers,
|
733 | TRawDocType,
|
734 | 'findOneAndUpdate',
|
735 | TInstanceMethods
|
736 | >;
|
737 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
738 | id: mongodb.ObjectId | any,
|
739 | update: UpdateQuery<TRawDocType>,
|
740 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
741 | ): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
742 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
743 | id: mongodb.ObjectId | any,
|
744 | update: UpdateQuery<TRawDocType>,
|
745 | options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
746 | ): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
747 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
748 | id?: mongodb.ObjectId | any,
|
749 | update?: UpdateQuery<TRawDocType>,
|
750 | options?: QueryOptions<TRawDocType> | null
|
751 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
752 | findByIdAndUpdate<ResultDoc = THydratedDocumentType>(
|
753 | id: mongodb.ObjectId | any,
|
754 | update: UpdateQuery<TRawDocType>
|
755 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
756 |
|
757 |
|
758 | findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
759 | filter: FilterQuery<TRawDocType>,
|
760 | options: QueryOptions<TRawDocType> & { lean: true }
|
761 | ): QueryWithHelpers<
|
762 | GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndDelete'> | null,
|
763 | ResultDoc,
|
764 | TQueryHelpers,
|
765 | TRawDocType,
|
766 | 'findOneAndDelete',
|
767 | TInstanceMethods
|
768 | >;
|
769 | findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
770 | filter: FilterQuery<TRawDocType>,
|
771 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
772 | ): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
773 | findOneAndDelete<ResultDoc = THydratedDocumentType>(
|
774 | filter?: FilterQuery<TRawDocType> | null,
|
775 | options?: QueryOptions<TRawDocType> | null
|
776 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndDelete', TInstanceMethods>;
|
777 |
|
778 |
|
779 | findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
780 | filter: FilterQuery<TRawDocType>,
|
781 | replacement: TRawDocType | AnyObject,
|
782 | options: QueryOptions<TRawDocType> & { lean: true }
|
783 | ): QueryWithHelpers<
|
784 | GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndReplace'> | null,
|
785 | ResultDoc,
|
786 | TQueryHelpers,
|
787 | TRawDocType,
|
788 | 'findOneAndReplace',
|
789 | TInstanceMethods
|
790 | >;
|
791 | findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
792 | filter: FilterQuery<TRawDocType>,
|
793 | replacement: TRawDocType | AnyObject,
|
794 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
795 | ): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
796 | findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
797 | filter: FilterQuery<TRawDocType>,
|
798 | replacement: TRawDocType | AnyObject,
|
799 | options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
800 | ): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
801 | findOneAndReplace<ResultDoc = THydratedDocumentType>(
|
802 | filter?: FilterQuery<TRawDocType>,
|
803 | replacement?: TRawDocType | AnyObject,
|
804 | options?: QueryOptions<TRawDocType> | null
|
805 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndReplace', TInstanceMethods>;
|
806 |
|
807 |
|
808 | findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
809 | filter: FilterQuery<TRawDocType>,
|
810 | update: UpdateQuery<TRawDocType>,
|
811 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true, lean: true }
|
812 | ): QueryWithHelpers<
|
813 | ModifyResult<TRawDocType>,
|
814 | ResultDoc,
|
815 | TQueryHelpers,
|
816 | TRawDocType,
|
817 | 'findOneAndUpdate',
|
818 | TInstanceMethods
|
819 | >;
|
820 | findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
821 | filter: FilterQuery<TRawDocType>,
|
822 | update: UpdateQuery<TRawDocType>,
|
823 | options: QueryOptions<TRawDocType> & { lean: true }
|
824 | ): QueryWithHelpers<
|
825 | GetLeanResultType<TRawDocType, TRawDocType, 'findOneAndUpdate'> | null,
|
826 | ResultDoc,
|
827 | TQueryHelpers,
|
828 | TRawDocType,
|
829 | 'findOneAndUpdate',
|
830 | TInstanceMethods
|
831 | >;
|
832 | findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
833 | filter: FilterQuery<TRawDocType>,
|
834 | update: UpdateQuery<TRawDocType>,
|
835 | options: QueryOptions<TRawDocType> & { includeResultMetadata: true }
|
836 | ): QueryWithHelpers<ModifyResult<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
837 | findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
838 | filter: FilterQuery<TRawDocType>,
|
839 | update: UpdateQuery<TRawDocType>,
|
840 | options: QueryOptions<TRawDocType> & { upsert: true } & ReturnsNewDoc
|
841 | ): QueryWithHelpers<ResultDoc, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
842 | findOneAndUpdate<ResultDoc = THydratedDocumentType>(
|
843 | filter?: FilterQuery<TRawDocType>,
|
844 | update?: UpdateQuery<TRawDocType>,
|
845 | options?: QueryOptions<TRawDocType> | null
|
846 | ): QueryWithHelpers<ResultDoc | null, ResultDoc, TQueryHelpers, TRawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
847 |
|
848 |
|
849 | replaceOne<ResultDoc = THydratedDocumentType>(
|
850 | filter?: FilterQuery<TRawDocType>,
|
851 | replacement?: TRawDocType | AnyObject,
|
852 | options?: (mongodb.ReplaceOptions & MongooseQueryOptions<TRawDocType>) | null
|
853 | ): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'replaceOne', TInstanceMethods>;
|
854 |
|
855 |
|
856 | recompileSchema(): void;
|
857 |
|
858 |
|
859 | schema: Schema<TRawDocType>;
|
860 |
|
861 |
|
862 | updateMany<ResultDoc = THydratedDocumentType>(
|
863 | filter?: FilterQuery<TRawDocType>,
|
864 | update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
865 | options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
866 | ): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateMany', TInstanceMethods>;
|
867 |
|
868 |
|
869 | updateOne<ResultDoc = THydratedDocumentType>(
|
870 | filter?: FilterQuery<TRawDocType>,
|
871 | update?: UpdateQuery<TRawDocType> | UpdateWithAggregationPipeline,
|
872 | options?: (mongodb.UpdateOptions & MongooseUpdateQueryOptions<TRawDocType>) | null
|
873 | ): QueryWithHelpers<UpdateWriteOpResult, ResultDoc, TQueryHelpers, TRawDocType, 'updateOne', TInstanceMethods>;
|
874 |
|
875 |
|
876 | where<ResultDoc = THydratedDocumentType>(
|
877 | path: string,
|
878 | val?: any
|
879 | ): QueryWithHelpers<Array<ResultDoc>, ResultDoc, TQueryHelpers, TRawDocType, 'find', TInstanceMethods>;
|
880 | where<ResultDoc = THydratedDocumentType>(obj: object): QueryWithHelpers<
|
881 | Array<ResultDoc>,
|
882 | ResultDoc,
|
883 | TQueryHelpers,
|
884 | TRawDocType,
|
885 | 'find',
|
886 | TInstanceMethods
|
887 | >;
|
888 | where<ResultDoc = THydratedDocumentType>(): QueryWithHelpers<
|
889 | Array<ResultDoc>,
|
890 | ResultDoc,
|
891 | TQueryHelpers,
|
892 | TRawDocType,
|
893 | 'find',
|
894 | TInstanceMethods
|
895 | >;
|
896 | }
|
897 | }
|