1 | declare module 'mongoose' {
|
2 | import mongodb = require('mongodb');
|
3 |
|
4 | export type Condition<T> = T | QuerySelector<T | any> | any;
|
5 |
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | type FilterQuery<T> = {
|
14 | [P in keyof T]?: Condition<T[P]>;
|
15 | } & RootQuerySelector<T>;
|
16 |
|
17 | type MongooseBaseQueryOptionKeys =
|
18 | | 'context'
|
19 | | 'multipleCastError'
|
20 | | 'overwriteDiscriminatorKey'
|
21 | | 'populate'
|
22 | | 'runValidators'
|
23 | | 'sanitizeProjection'
|
24 | | 'sanitizeFilter'
|
25 | | 'setDefaultsOnInsert'
|
26 | | 'strict'
|
27 | | 'strictQuery'
|
28 | | 'translateAliases';
|
29 |
|
30 | type MongooseQueryOptions<
|
31 | DocType = unknown,
|
32 | Keys extends keyof QueryOptions<DocType> = MongooseBaseQueryOptionKeys | 'timestamps' | 'lean'
|
33 | > = Pick<QueryOptions<DocType>, Keys> & {
|
34 | [other: string]: any;
|
35 | };
|
36 |
|
37 | type MongooseBaseQueryOptions<DocType = unknown> = MongooseQueryOptions<DocType, MongooseBaseQueryOptionKeys>;
|
38 |
|
39 | type MongooseUpdateQueryOptions<DocType = unknown> = MongooseQueryOptions<
|
40 | DocType,
|
41 | MongooseBaseQueryOptionKeys | 'timestamps'
|
42 | >;
|
43 |
|
44 | type ProjectionFields<DocType> = { [Key in keyof DocType]?: any } & Record<string, any>;
|
45 |
|
46 | type QueryWithHelpers<
|
47 | ResultType,
|
48 | DocType,
|
49 | THelpers = {},
|
50 | RawDocType = DocType,
|
51 | QueryOp = 'find',
|
52 | TInstanceMethods = Record<string, never>
|
53 | > = Query<ResultType, DocType, THelpers, RawDocType, QueryOp, TInstanceMethods> & THelpers;
|
54 |
|
55 | type QuerySelector<T> = {
|
56 |
|
57 | $eq?: T;
|
58 | $gt?: T;
|
59 | $gte?: T;
|
60 | $in?: [T] extends AnyArray<any> ? Unpacked<T>[] : T[];
|
61 | $lt?: T;
|
62 | $lte?: T;
|
63 | $ne?: T;
|
64 | $nin?: [T] extends AnyArray<any> ? Unpacked<T>[] : T[];
|
65 |
|
66 | $not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>;
|
67 |
|
68 | |
69 |
|
70 |
|
71 |
|
72 | $exists?: boolean;
|
73 | $type?: string | number;
|
74 |
|
75 | $expr?: any;
|
76 | $jsonSchema?: any;
|
77 | $mod?: T extends number ? [number, number] : never;
|
78 | $regex?: T extends string ? RegExp | string : never;
|
79 | $options?: T extends string ? string : never;
|
80 |
|
81 |
|
82 | $geoIntersects?: { $geometry: object };
|
83 | $geoWithin?: object;
|
84 | $near?: object;
|
85 | $nearSphere?: object;
|
86 | $maxDistance?: number;
|
87 |
|
88 |
|
89 | $all?: T extends AnyArray<any> ? any[] : never;
|
90 | $elemMatch?: T extends AnyArray<any> ? object : never;
|
91 | $size?: T extends AnyArray<any> ? number : never;
|
92 |
|
93 | $bitsAllClear?: number | mongodb.Binary | number[];
|
94 | $bitsAllSet?: number | mongodb.Binary | number[];
|
95 | $bitsAnyClear?: number | mongodb.Binary | number[];
|
96 | $bitsAnySet?: number | mongodb.Binary | number[];
|
97 | };
|
98 |
|
99 | type RootQuerySelector<T> = {
|
100 |
|
101 | $and?: Array<FilterQuery<T>>;
|
102 |
|
103 | $nor?: Array<FilterQuery<T>>;
|
104 |
|
105 | $or?: Array<FilterQuery<T>>;
|
106 |
|
107 | $text?: {
|
108 | $search: string;
|
109 | $language?: string;
|
110 | $caseSensitive?: boolean;
|
111 | $diacriticSensitive?: boolean;
|
112 | };
|
113 |
|
114 | $where?: string | Function;
|
115 |
|
116 | $comment?: string;
|
117 |
|
118 |
|
119 | [key: string]: any;
|
120 | };
|
121 |
|
122 | interface QueryTimestampsConfig {
|
123 | createdAt?: boolean;
|
124 | updatedAt?: boolean;
|
125 | }
|
126 |
|
127 | interface QueryOptions<DocType = unknown> extends
|
128 | PopulateOption,
|
129 | SessionOption {
|
130 | arrayFilters?: { [key: string]: any }[];
|
131 | batchSize?: number;
|
132 | collation?: mongodb.CollationOptions;
|
133 | comment?: any;
|
134 | context?: string;
|
135 | explain?: mongodb.ExplainVerbosityLike;
|
136 | fields?: any | string;
|
137 | hint?: mongodb.Hint;
|
138 | |
139 |
|
140 |
|
141 | lean?: boolean | Record<string, any>;
|
142 | limit?: number;
|
143 | maxTimeMS?: number;
|
144 | multi?: boolean;
|
145 | multipleCastError?: boolean;
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 | new?: boolean;
|
152 |
|
153 | overwriteDiscriminatorKey?: boolean;
|
154 | projection?: ProjectionType<DocType>;
|
155 | |
156 |
|
157 |
|
158 | includeResultMetadata?: boolean;
|
159 | readPreference?: string | mongodb.ReadPreferenceMode;
|
160 | |
161 |
|
162 |
|
163 | returnOriginal?: boolean;
|
164 | |
165 |
|
166 |
|
167 | returnDocument?: 'before' | 'after';
|
168 | |
169 |
|
170 |
|
171 |
|
172 | runValidators?: boolean;
|
173 |
|
174 | sanitizeProjection?: boolean;
|
175 | |
176 |
|
177 |
|
178 |
|
179 | sanitizeFilter?: boolean;
|
180 | setDefaultsOnInsert?: boolean;
|
181 | skip?: number;
|
182 | sort?: any;
|
183 |
|
184 | strict?: boolean | string;
|
185 | |
186 |
|
187 |
|
188 |
|
189 | strictQuery?: boolean | 'throw';
|
190 | tailable?: number;
|
191 | |
192 |
|
193 |
|
194 |
|
195 |
|
196 | timestamps?: boolean | QueryTimestampsConfig;
|
197 | |
198 |
|
199 |
|
200 |
|
201 | translateAliases?: boolean;
|
202 | upsert?: boolean;
|
203 | useBigInt64?: boolean;
|
204 | writeConcern?: mongodb.WriteConcern;
|
205 |
|
206 | [other: string]: any;
|
207 | }
|
208 |
|
209 | type QueryOpThatReturnsDocument = 'find' | 'findOne' | 'findOneAndUpdate' | 'findOneAndReplace' | 'findOneAndDelete';
|
210 |
|
211 | type GetLeanResultType<RawDocType, ResultType, QueryOp> = QueryOp extends QueryOpThatReturnsDocument
|
212 | ? (ResultType extends any[] ? Require_id<FlattenMaps<RawDocType>>[] : Require_id<FlattenMaps<RawDocType>>)
|
213 | : ResultType;
|
214 |
|
215 | type MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, TQueryHelpers, TInstanceMethods = Record<string, never>> = QueryOp extends QueryOpThatReturnsDocument
|
216 | ? ResultType extends null
|
217 | ? ResultType
|
218 | : ResultType extends (infer U)[]
|
219 | ? U extends Document
|
220 | ? HydratedDocument<MergeType<RawDocType, Paths>, TInstanceMethods, TQueryHelpers>[]
|
221 | : (MergeType<U, Paths>)[]
|
222 | : ResultType extends Document
|
223 | ? HydratedDocument<MergeType<RawDocType, Paths>, TInstanceMethods, TQueryHelpers>
|
224 | : MergeType<ResultType, Paths>
|
225 | : MergeType<ResultType, Paths>;
|
226 |
|
227 | class Query<ResultType, DocType, THelpers = {}, RawDocType = DocType, QueryOp = 'find', TInstanceMethods = Record<string, never>> implements SessionOperation {
|
228 | _mongooseOptions: MongooseQueryOptions<DocType>;
|
229 |
|
230 | |
231 |
|
232 |
|
233 |
|
234 |
|
235 | [Symbol.asyncIterator](): AsyncIterableIterator<Unpacked<ResultType>>;
|
236 |
|
237 |
|
238 | exec(): Promise<ResultType>;
|
239 |
|
240 | $where(argument: string | Function): QueryWithHelpers<
|
241 | DocType[],
|
242 | DocType,
|
243 | THelpers,
|
244 | RawDocType,
|
245 | QueryOp,
|
246 | TInstanceMethods
|
247 | >;
|
248 |
|
249 |
|
250 | all(path: string, val: Array<any>): this;
|
251 | all(val: Array<any>): this;
|
252 |
|
253 |
|
254 | allowDiskUse(value: boolean): this;
|
255 |
|
256 |
|
257 | and(array: FilterQuery<RawDocType>[]): this;
|
258 |
|
259 |
|
260 | batchSize(val: number): this;
|
261 |
|
262 |
|
263 | box(lower: number[], upper: number[]): this;
|
264 | box(val: any): this;
|
265 |
|
266 | |
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | cast(model?: Model<any, THelpers> | null, obj?: any): any;
|
274 |
|
275 | |
276 |
|
277 |
|
278 |
|
279 |
|
280 | catch: Promise<ResultType>['catch'];
|
281 |
|
282 | |
283 |
|
284 |
|
285 |
|
286 | finally: Promise<ResultType>['finally'];
|
287 |
|
288 |
|
289 | [Symbol.toStringTag]: string;
|
290 |
|
291 |
|
292 | circle(path: string, area: any): this;
|
293 | circle(area: any): this;
|
294 |
|
295 |
|
296 | clone(): this;
|
297 |
|
298 |
|
299 | collation(value: mongodb.CollationOptions): this;
|
300 |
|
301 |
|
302 | comment(val: string): this;
|
303 |
|
304 |
|
305 | countDocuments(
|
306 | criteria?: FilterQuery<RawDocType>,
|
307 | options?: QueryOptions<DocType>
|
308 | ): QueryWithHelpers<number, DocType, THelpers, RawDocType, 'countDocuments', TInstanceMethods>;
|
309 |
|
310 | |
311 |
|
312 |
|
313 |
|
314 | cursor(options?: QueryOptions<DocType>): Cursor<Unpacked<ResultType>, QueryOptions<DocType>>;
|
315 |
|
316 | |
317 |
|
318 |
|
319 |
|
320 |
|
321 | deleteMany(
|
322 | filter?: FilterQuery<RawDocType>,
|
323 | options?: QueryOptions<DocType>
|
324 | ): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TInstanceMethods>;
|
325 | deleteMany(filter: FilterQuery<RawDocType>): QueryWithHelpers<
|
326 | any,
|
327 | DocType,
|
328 | THelpers,
|
329 | RawDocType,
|
330 | 'deleteMany',
|
331 | TInstanceMethods
|
332 | >;
|
333 | deleteMany(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteMany', TInstanceMethods>;
|
334 |
|
335 | |
336 |
|
337 |
|
338 |
|
339 |
|
340 | deleteOne(
|
341 | filter?: FilterQuery<RawDocType>,
|
342 | options?: QueryOptions<DocType>
|
343 | ): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TInstanceMethods>;
|
344 | deleteOne(filter: FilterQuery<RawDocType>): QueryWithHelpers<
|
345 | any,
|
346 | DocType,
|
347 | THelpers,
|
348 | RawDocType,
|
349 | 'deleteOne',
|
350 | TInstanceMethods
|
351 | >;
|
352 | deleteOne(): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'deleteOne', TInstanceMethods>;
|
353 |
|
354 |
|
355 | distinct<DocKey extends string, ResultType = unknown>(
|
356 | field: DocKey,
|
357 | filter?: FilterQuery<RawDocType>
|
358 | ): QueryWithHelpers<
|
359 | Array<
|
360 | DocKey extends keyof WithLevel1NestedPaths<DocType>
|
361 | ? WithoutUndefined<Unpacked<WithLevel1NestedPaths<DocType>[DocKey]>>
|
362 | : ResultType
|
363 | >,
|
364 | DocType,
|
365 | THelpers,
|
366 | RawDocType,
|
367 | 'distinct',
|
368 | TInstanceMethods
|
369 | >;
|
370 |
|
371 |
|
372 | elemMatch<K = string>(path: K, val: any): this;
|
373 | elemMatch(val: Function | any): this;
|
374 |
|
375 | |
376 |
|
377 |
|
378 |
|
379 | error(): NativeError | null;
|
380 | error(val: NativeError | null): this;
|
381 |
|
382 |
|
383 | equals(val: any): this;
|
384 |
|
385 |
|
386 | estimatedDocumentCount(options?: QueryOptions<DocType>): QueryWithHelpers<
|
387 | number,
|
388 | DocType,
|
389 | THelpers,
|
390 | RawDocType,
|
391 | 'estimatedDocumentCount',
|
392 | TInstanceMethods
|
393 | >;
|
394 |
|
395 |
|
396 | exists<K = string>(path: K, val: boolean): this;
|
397 | exists(val: boolean): this;
|
398 |
|
399 | |
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 | explain(verbose?: mongodb.ExplainVerbosityLike): this;
|
406 |
|
407 |
|
408 | find(
|
409 | filter: FilterQuery<RawDocType>,
|
410 | projection?: ProjectionType<RawDocType> | null,
|
411 | options?: QueryOptions<DocType> | null
|
412 | ): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TInstanceMethods>;
|
413 | find(
|
414 | filter: FilterQuery<RawDocType>,
|
415 | projection?: ProjectionType<RawDocType> | null
|
416 | ): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TInstanceMethods>;
|
417 | find(
|
418 | filter: FilterQuery<RawDocType>
|
419 | ): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TInstanceMethods>;
|
420 | find(): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find', TInstanceMethods>;
|
421 |
|
422 |
|
423 | findOne(
|
424 | filter?: FilterQuery<RawDocType>,
|
425 | projection?: ProjectionType<RawDocType> | null,
|
426 | options?: QueryOptions<DocType> | null
|
427 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
428 | findOne(
|
429 | filter?: FilterQuery<RawDocType>,
|
430 | projection?: ProjectionType<RawDocType> | null
|
431 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
432 | findOne(
|
433 | filter?: FilterQuery<RawDocType>
|
434 | ): QueryWithHelpers<DocType | null, RawDocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
435 |
|
436 |
|
437 | findOneAndDelete(
|
438 | filter?: FilterQuery<RawDocType>,
|
439 | options?: QueryOptions<DocType> | null
|
440 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete'>;
|
441 |
|
442 |
|
443 | findOneAndUpdate(
|
444 | filter: FilterQuery<RawDocType>,
|
445 | update: UpdateQuery<RawDocType>,
|
446 | options: QueryOptions<DocType> & { includeResultMetadata: true }
|
447 | ): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
448 | findOneAndUpdate(
|
449 | filter: FilterQuery<RawDocType>,
|
450 | update: UpdateQuery<RawDocType>,
|
451 | options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc
|
452 | ): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
453 | findOneAndUpdate(
|
454 | filter?: FilterQuery<RawDocType>,
|
455 | update?: UpdateQuery<RawDocType>,
|
456 | options?: QueryOptions<DocType> | null
|
457 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
458 |
|
459 |
|
460 | findById(
|
461 | id: mongodb.ObjectId | any,
|
462 | projection?: ProjectionType<RawDocType> | null,
|
463 | options?: QueryOptions<DocType> | null
|
464 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
465 | findById(
|
466 | id: mongodb.ObjectId | any,
|
467 | projection?: ProjectionType<RawDocType> | null
|
468 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
469 | findById(
|
470 | id: mongodb.ObjectId | any
|
471 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOne', TInstanceMethods>;
|
472 |
|
473 |
|
474 | findByIdAndDelete(
|
475 | id: mongodb.ObjectId | any,
|
476 | options: QueryOptions<DocType> & { includeResultMetadata: true }
|
477 | ): QueryWithHelpers<ModifyResult<DocType>, DocType, THelpers, RawDocType, 'findOneAndDelete', TInstanceMethods>;
|
478 | findByIdAndDelete(
|
479 | id?: mongodb.ObjectId | any,
|
480 | options?: QueryOptions<DocType> | null
|
481 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndDelete', TInstanceMethods>;
|
482 |
|
483 |
|
484 | findByIdAndUpdate(
|
485 | id: mongodb.ObjectId | any,
|
486 | update: UpdateQuery<RawDocType>,
|
487 | options: QueryOptions<DocType> & { includeResultMetadata: true }
|
488 | ): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
489 | findByIdAndUpdate(
|
490 | id: mongodb.ObjectId | any,
|
491 | update: UpdateQuery<RawDocType>,
|
492 | options: QueryOptions<DocType> & { upsert: true } & ReturnsNewDoc
|
493 | ): QueryWithHelpers<DocType, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
494 | findByIdAndUpdate(
|
495 | id?: mongodb.ObjectId | any,
|
496 | update?: UpdateQuery<RawDocType>,
|
497 | options?: QueryOptions<DocType> | null
|
498 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
499 | findByIdAndUpdate(
|
500 | id: mongodb.ObjectId | any,
|
501 | update: UpdateQuery<RawDocType>
|
502 | ): QueryWithHelpers<DocType | null, DocType, THelpers, RawDocType, 'findOneAndUpdate', TInstanceMethods>;
|
503 |
|
504 |
|
505 | geometry(object: { type: string, coordinates: any[] }): this;
|
506 |
|
507 | |
508 |
|
509 |
|
510 |
|
511 |
|
512 | get(path: string): any;
|
513 |
|
514 |
|
515 | getFilter(): FilterQuery<RawDocType>;
|
516 |
|
517 |
|
518 | getOptions(): QueryOptions<DocType>;
|
519 |
|
520 |
|
521 | getPopulatedPaths(): Array<string>;
|
522 |
|
523 |
|
524 | getQuery(): FilterQuery<RawDocType>;
|
525 |
|
526 |
|
527 | getUpdate(): UpdateQuery<DocType> | UpdateWithAggregationPipeline | null;
|
528 |
|
529 |
|
530 | gt<K = string>(path: K, val: any): this;
|
531 | gt(val: number): this;
|
532 |
|
533 |
|
534 | gte<K = string>(path: K, val: any): this;
|
535 | gte(val: number): this;
|
536 |
|
537 |
|
538 | hint(val: any): this;
|
539 |
|
540 |
|
541 | in<K = string>(path: K, val: any[]): this;
|
542 | in(val: Array<any>): this;
|
543 |
|
544 |
|
545 | intersects(arg?: any): this;
|
546 |
|
547 |
|
548 | j(val: boolean | null): this;
|
549 |
|
550 |
|
551 | lean<
|
552 | LeanResultType = GetLeanResultType<RawDocType, ResultType, QueryOp>
|
553 | >(
|
554 | val?: boolean | any
|
555 | ): QueryWithHelpers<
|
556 | ResultType extends null
|
557 | ? LeanResultType | null
|
558 | : LeanResultType,
|
559 | DocType,
|
560 | THelpers,
|
561 | RawDocType,
|
562 | QueryOp,
|
563 | TInstanceMethods
|
564 | >;
|
565 |
|
566 |
|
567 | limit(val: number): this;
|
568 |
|
569 |
|
570 | lt<K = string>(path: K, val: any): this;
|
571 | lt(val: number): this;
|
572 |
|
573 |
|
574 | lte<K = string>(path: K, val: any): this;
|
575 | lte(val: number): this;
|
576 |
|
577 | |
578 |
|
579 |
|
580 |
|
581 | transform<MappedType>(fn: (doc: ResultType) => MappedType): QueryWithHelpers<MappedType, DocType, THelpers, RawDocType, QueryOp, TInstanceMethods>;
|
582 |
|
583 | /** Specifies an `$maxDistance` query condition. When called with one argument, the most recent path passed to `where()` is used. */
|
584 | maxDistance(path: string, val: number): this;
|
585 | maxDistance(val: number): this;
|
586 |
|
587 | /**
|
588 | * Sets the [maxTimeMS](https:
|
589 | * option. This will tell the MongoDB server to abort if the query or write op
|
590 | * has been running for more than `ms` milliseconds.
|
591 | */
|
592 | maxTimeMS(ms: number): this;
|
593 |
|
594 |
|
595 | merge(source: Query<any, any> | FilterQuery<RawDocType>): this;
|
596 |
|
597 |
|
598 | mod<K = string>(path: K, val: number): this;
|
599 | mod(val: Array<number>): this;
|
600 |
|
601 |
|
602 | model: Model<any>;
|
603 |
|
604 | |
605 |
|
606 |
|
607 |
|
608 | mongooseOptions(val?: MongooseQueryOptions): MongooseQueryOptions;
|
609 |
|
610 |
|
611 | ne<K = string>(path: K, val: any): this;
|
612 | ne(val: any): this;
|
613 |
|
614 |
|
615 | near<K = string>(path: K, val: any): this;
|
616 | near(val: any): this;
|
617 |
|
618 |
|
619 | nin<K = string>(path: K, val: any[]): this;
|
620 | nin(val: Array<any>): this;
|
621 |
|
622 |
|
623 | nor(array: Array<FilterQuery<RawDocType>>): this;
|
624 |
|
625 |
|
626 | or(array: Array<FilterQuery<RawDocType>>): this;
|
627 |
|
628 | |
629 |
|
630 |
|
631 |
|
632 |
|
633 | orFail(err?: NativeError | (() => NativeError)): QueryWithHelpers<NonNullable<ResultType>, DocType, THelpers, RawDocType, QueryOp, TInstanceMethods>;
|
634 |
|
635 |
|
636 | polygon(path: string, ...coordinatePairs: number[][]): this;
|
637 | polygon(...coordinatePairs: number[][]): this;
|
638 |
|
639 |
|
640 | populate(
|
641 | path: string | string[],
|
642 | select?: string | any,
|
643 | model?: string | Model<any, THelpers>,
|
644 | match?: any
|
645 | ): QueryWithHelpers<
|
646 | ResultType,
|
647 | DocType,
|
648 | THelpers,
|
649 | RawDocType,
|
650 | QueryOp,
|
651 | TInstanceMethods
|
652 | >;
|
653 | populate(
|
654 | options: PopulateOptions | (PopulateOptions | string)[]
|
655 | ): QueryWithHelpers<
|
656 | ResultType,
|
657 | DocType,
|
658 | THelpers,
|
659 | RawDocType,
|
660 | QueryOp,
|
661 | TInstanceMethods
|
662 | >;
|
663 | populate<Paths>(
|
664 | path: string | string[],
|
665 | select?: string | any,
|
666 | model?: string | Model<any, THelpers>,
|
667 | match?: any
|
668 | ): QueryWithHelpers<
|
669 | MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, THelpers, TInstanceMethods>,
|
670 | DocType,
|
671 | THelpers,
|
672 | UnpackedIntersection<RawDocType, Paths>,
|
673 | QueryOp,
|
674 | TInstanceMethods
|
675 | >;
|
676 | populate<Paths>(
|
677 | options: PopulateOptions | (PopulateOptions | string)[]
|
678 | ): QueryWithHelpers<
|
679 | MergePopulatePaths<RawDocType, ResultType, QueryOp, Paths, THelpers, TInstanceMethods>,
|
680 | DocType,
|
681 | THelpers,
|
682 | UnpackedIntersection<RawDocType, Paths>,
|
683 | QueryOp,
|
684 | TInstanceMethods
|
685 | >;
|
686 |
|
687 |
|
688 | pre(fn: Function): this;
|
689 |
|
690 |
|
691 | post(fn: Function): this;
|
692 |
|
693 |
|
694 | projection(fields?: ProjectionFields<DocType> | string): ProjectionFields<DocType>;
|
695 | projection(fields: null): null;
|
696 | projection(): ProjectionFields<DocType> | null;
|
697 |
|
698 |
|
699 | read(mode: string | mongodb.ReadPreferenceMode, tags?: any[]): this;
|
700 |
|
701 |
|
702 | readConcern(level: string): this;
|
703 |
|
704 |
|
705 | regex<K = string>(path: K, val: RegExp): this;
|
706 | regex(val: string | RegExp): this;
|
707 |
|
708 | |
709 |
|
710 |
|
711 |
|
712 |
|
713 | replaceOne(
|
714 | filter?: FilterQuery<RawDocType>,
|
715 | replacement?: DocType | AnyObject,
|
716 | options?: QueryOptions<DocType> | null
|
717 | ): QueryWithHelpers<any, DocType, THelpers, RawDocType, 'replaceOne', TInstanceMethods>;
|
718 |
|
719 | |
720 |
|
721 |
|
722 | sanitizeProjection(value: boolean): this;
|
723 |
|
724 |
|
725 | select<RawDocTypeOverride extends { [P in keyof RawDocType]?: any } = {}>(
|
726 | arg: string | string[] | Record<string, number | boolean | string | object>
|
727 | ): QueryWithHelpers<
|
728 | IfEquals<
|
729 | RawDocTypeOverride,
|
730 | {},
|
731 | ResultType,
|
732 | ResultType extends any[]
|
733 | ? ResultType extends HydratedDocument<any>[]
|
734 | ? HydratedDocument<RawDocTypeOverride>[]
|
735 | : RawDocTypeOverride[]
|
736 | : (ResultType extends HydratedDocument<any>
|
737 | ? HydratedDocument<RawDocTypeOverride>
|
738 | : RawDocTypeOverride) | (null extends ResultType ? null : never)
|
739 | >,
|
740 | DocType,
|
741 | THelpers,
|
742 | IfEquals<
|
743 | RawDocTypeOverride,
|
744 | {},
|
745 | RawDocType,
|
746 | RawDocTypeOverride
|
747 | >,
|
748 | QueryOp,
|
749 | TInstanceMethods
|
750 | >;
|
751 |
|
752 |
|
753 | selected(): boolean;
|
754 |
|
755 |
|
756 | selectedExclusively(): boolean;
|
757 |
|
758 |
|
759 | selectedInclusively(): boolean;
|
760 |
|
761 | |
762 |
|
763 |
|
764 |
|
765 |
|
766 | session(session: mongodb.ClientSession | null): this;
|
767 |
|
768 | |
769 |
|
770 |
|
771 |
|
772 |
|
773 | set(path: string | Record<string, unknown>, value?: any): this;
|
774 |
|
775 |
|
776 | setOptions(options: QueryOptions<DocType>, overwrite?: boolean): this;
|
777 |
|
778 |
|
779 | setQuery(val: FilterQuery<RawDocType> | null): void;
|
780 |
|
781 | setUpdate(update: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline): void;
|
782 |
|
783 |
|
784 | size<K = string>(path: K, val: number): this;
|
785 | size(val: number): this;
|
786 |
|
787 |
|
788 | skip(val: number): this;
|
789 |
|
790 |
|
791 | slice(path: string, val: number | Array<number>): this;
|
792 | slice(val: number | Array<number>): this;
|
793 |
|
794 |
|
795 | sort(
|
796 | arg?: string | { [key: string]: SortOrder | { $meta: any } } | [string, SortOrder][] | undefined | null,
|
797 | options?: { override?: boolean }
|
798 | ): this;
|
799 |
|
800 |
|
801 | tailable(bool?: boolean, opts?: {
|
802 | numberOfRetries?: number;
|
803 | tailableRetryInterval?: number;
|
804 | }): this;
|
805 |
|
806 | |
807 |
|
808 |
|
809 |
|
810 | then: Promise<ResultType>['then'];
|
811 |
|
812 |
|
813 | toConstructor<RetType = typeof Query>(): RetType;
|
814 |
|
815 | |
816 |
|
817 |
|
818 |
|
819 |
|
820 |
|
821 | updateMany(
|
822 | filter?: FilterQuery<RawDocType>,
|
823 | update?: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
824 | options?: QueryOptions<DocType> | null
|
825 | ): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateMany', TInstanceMethods>;
|
826 |
|
827 | |
828 |
|
829 |
|
830 |
|
831 | updateOne(
|
832 | filter?: FilterQuery<RawDocType>,
|
833 | update?: UpdateQuery<RawDocType> | UpdateWithAggregationPipeline,
|
834 | options?: QueryOptions<DocType> | null
|
835 | ): QueryWithHelpers<UpdateWriteOpResult, DocType, THelpers, RawDocType, 'updateOne', TInstanceMethods>;
|
836 |
|
837 | |
838 |
|
839 |
|
840 |
|
841 | w(val: string | number | null): this;
|
842 |
|
843 |
|
844 | where(path: string, val?: any): this;
|
845 | where(obj: object): this;
|
846 | where(): this;
|
847 |
|
848 |
|
849 | within(val?: any): this;
|
850 |
|
851 | |
852 |
|
853 |
|
854 |
|
855 |
|
856 | wtimeout(ms: number): this;
|
857 | }
|
858 | }
|
859 |
|
\ | No newline at end of file |