1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | import { Binary, Decimal128, Double, Int32, Long, ObjectId, Timestamp } from 'bson';
|
44 | import { EventEmitter } from 'events';
|
45 | import { Readable, Writable } from 'stream';
|
46 | import { checkServerIdentity } from 'tls';
|
47 |
|
48 |
|
49 | type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
50 |
|
51 | type FlattenIfArray<T> = T extends ReadonlyArray<infer R> ? R : T;
|
52 |
|
53 | export function connect(uri: string, options?: MongoClientOptions): Promise<MongoClient>;
|
54 | export function connect(uri: string, callback: MongoCallback<MongoClient>): void;
|
55 | export function connect(uri: string, options: MongoClientOptions, callback: MongoCallback<MongoClient>): void;
|
56 |
|
57 | export { Binary, DBRef, Decimal128, Double, Int32, Long, MaxKey, MinKey, ObjectID, ObjectId, Timestamp } from 'bson';
|
58 |
|
59 | type NumericTypes = number | Decimal128 | Double | Int32 | Long;
|
60 |
|
61 |
|
62 | export class MongoClient extends EventEmitter {
|
63 | constructor(uri: string, options?: MongoClientOptions);
|
64 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#.connect */
|
65 | static connect(uri: string, callback: MongoCallback<MongoClient>): void;
|
66 | static connect(uri: string, options?: MongoClientOptions): Promise<MongoClient>;
|
67 | static connect(uri: string, options: MongoClientOptions, callback: MongoCallback<MongoClient>): void;
|
68 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#connect */
|
69 | connect(): Promise<MongoClient>;
|
70 | connect(callback: MongoCallback<MongoClient>): void;
|
71 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#close */
|
72 | close(callback: MongoCallback<void>): void;
|
73 | close(force?: boolean): Promise<void>;
|
74 | close(force: boolean, callback: MongoCallback<void>): void;
|
75 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#db */
|
76 | db(dbName?: string, options?: MongoClientCommonOption): Db;
|
77 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#isConnected */
|
78 | isConnected(options?: MongoClientCommonOption): boolean;
|
79 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#logout */
|
80 | logout(callback: MongoCallback<any>): void;
|
81 | logout(options?: { dbName?: string }): Promise<any>;
|
82 | logout(options: { dbName?: string }, callback: MongoCallback<any>): void;
|
83 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#startSession */
|
84 | startSession(options?: SessionOptions): ClientSession;
|
85 | /** http://mongodb.github.io/node-mongodb-native/3.3/api/MongoClient.html#watch */
|
86 | watch<TSchema extends object = { _id: ObjectId }>(
|
87 | pipeline?: object[],
|
88 | options?: ChangeStreamOptions & { session?: ClientSession },
|
89 | ): ChangeStream<TSchema>;
|
90 |
|
91 | withSession(operation: (session: ClientSession) => Promise<any>): Promise<void>;
|
92 |
|
93 | withSession(options: SessionOptions, operation: (session: ClientSession) => Promise<any>): Promise<void>;
|
94 |
|
95 | readPreference: ReadPreference;
|
96 | writeConcern: WriteConcern;
|
97 | }
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export interface ClientSession extends EventEmitter {
|
103 |
|
104 | id: any;
|
105 | |
106 |
|
107 |
|
108 |
|
109 | abortTransaction(cb?: MongoCallback<void>): Promise<void>;
|
110 | |
111 |
|
112 |
|
113 | advanceOperationTime(operamtionTime: Timestamp): void;
|
114 | |
115 |
|
116 |
|
117 |
|
118 | commitTransaction(cb?: MongoCallback<void>): Promise<void>;
|
119 |
|
120 | |
121 |
|
122 |
|
123 |
|
124 | endSession(cb?: MongoCallback<void>): void;
|
125 | |
126 |
|
127 |
|
128 |
|
129 |
|
130 | endSession(options: any, cb?: MongoCallback<void>): void;
|
131 |
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | equals(session: ClientSession): boolean;
|
139 |
|
140 |
|
141 | incrementTransactionNumber(): void;
|
142 |
|
143 | |
144 |
|
145 |
|
146 | inTransaction(): boolean;
|
147 |
|
148 | |
149 |
|
150 |
|
151 | startTransaction(options?: TransactionOptions): void;
|
152 |
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | withTransaction<T>(fn: WithTransactionCallback<T>, options?: TransactionOptions): Promise<void>;
|
165 | }
|
166 |
|
167 |
|
168 | type ReadConcernLevel = 'local' | 'available' | 'majority' | 'linearizable' | 'snapshot';
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | export interface ReadConcern {
|
176 | level: ReadConcernLevel;
|
177 | }
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | interface WriteConcern {
|
185 | |
186 |
|
187 |
|
188 |
|
189 |
|
190 | w?: number | 'majority' | string;
|
191 | |
192 |
|
193 |
|
194 |
|
195 |
|
196 | j?: boolean;
|
197 | |
198 |
|
199 |
|
200 | wtimeout?: number;
|
201 | }
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 | export interface SessionOptions {
|
208 | |
209 |
|
210 |
|
211 |
|
212 | causalConsistency?: boolean;
|
213 | |
214 |
|
215 |
|
216 | defaultTransactionOptions?: TransactionOptions;
|
217 | }
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | export interface TransactionOptions {
|
224 | readConcern?: ReadConcern;
|
225 | writeConcern?: WriteConcern;
|
226 | readPreference?: ReadPreferenceOrMode;
|
227 | }
|
228 |
|
229 | export interface MongoClientCommonOption {
|
230 |
|
231 | noListener?: boolean;
|
232 |
|
233 | returnNonCachedInstance?: boolean;
|
234 | }
|
235 |
|
236 | export interface MongoCallback<T> {
|
237 | (error: MongoError, result: T): void;
|
238 | }
|
239 |
|
240 | export type WithTransactionCallback<T> = (session: ClientSession) => Promise<T>;
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 | export class MongoError extends Error {
|
247 | constructor(message: string | Error | object);
|
248 | /**
|
249 | * @deprecated
|
250 | */
|
251 | static create(options: string | Error | object): MongoError;
|
252 | /**
|
253 | * Checks the error to see if it has an error label
|
254 | */
|
255 | hasErrorLabel(label: string): boolean;
|
256 | code?: number | string;
|
257 | /**
|
258 | * While not documented, the 'errmsg' prop is AFAIK the only way to find out
|
259 | * which unique index caused a duplicate key error. When you have multiple
|
260 | * unique indexes on a collection, knowing which index caused a duplicate
|
261 | * key error enables you to send better (more precise) error messages to the
|
262 | * client/user (eg. "Email address must be unique" instead of "Both email
|
263 | * address and username must be unique") - which caters for a better (app)
|
264 | * user experience.
|
265 | *
|
266 | * Details: https://github.com/Automattic/mongoose/issues/2129 (issue for
|
267 | * mongoose, but the same applies for the native mongodb driver)
|
268 | *
|
269 | * Note that in mongoose (the link above) the prop in question is called
|
270 | * 'message' while in mongodb it is called 'errmsg'. This can be seen in
|
271 | * multiple places in the source code, for example here:
|
272 | * https://github.com/mongodb/node-mongodb-native/blob/a12aa15ac3eaae3ad5c4166ea1423aec4560f155/test/functional/find_tests.js#L1111
|
273 | */
|
274 | errmsg?: string;
|
275 | name: string;
|
276 | }
|
277 |
|
278 | /**
|
279 | * An error indicating an issue with the network, including TCP errors and timeouts
|
280 | * see {@link https:
|
281 | */
|
282 | export class MongoNetworkError extends MongoError {
|
283 | constructor(message: string);
|
284 | errorLabels: string[];
|
285 | }
|
286 |
|
287 | /**
|
288 | * An error used when attempting to parse a value (like a connection string)
|
289 | * see {@link https:
|
290 | */
|
291 | export class MongoParseError extends MongoError {
|
292 | constructor(message: string);
|
293 | }
|
294 |
|
295 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#.connect */
|
296 | export interface MongoClientOptions
|
297 | extends DbCreateOptions,
|
298 | ServerOptions,
|
299 | MongosOptions,
|
300 | ReplSetOptions,
|
301 | SocketOptions,
|
302 | SSLOptions,
|
303 | TLSOptions,
|
304 | HighAvailabilityOptions,
|
305 | WriteConcern,
|
306 | UnifiedTopologyOptions {
|
307 | |
308 |
|
309 |
|
310 | loggerLevel?: string;
|
311 |
|
312 | |
313 |
|
314 |
|
315 | logger?: object | log;
|
316 |
|
317 | |
318 |
|
319 |
|
320 |
|
321 | validateOptions?: object | boolean;
|
322 |
|
323 | |
324 |
|
325 |
|
326 | appname?: string;
|
327 |
|
328 | |
329 |
|
330 |
|
331 | auth?: {
|
332 | |
333 |
|
334 |
|
335 | user: string;
|
336 | |
337 |
|
338 |
|
339 | password: string;
|
340 | };
|
341 |
|
342 | |
343 |
|
344 |
|
345 |
|
346 |
|
347 | useNewUrlParser?: boolean;
|
348 |
|
349 | |
350 |
|
351 |
|
352 |
|
353 | numberOfRetries?: number;
|
354 |
|
355 | |
356 |
|
357 |
|
358 | authMechanism?:
|
359 | | 'DEFAULT'
|
360 | | 'GSSAPI'
|
361 | | 'PLAIN'
|
362 | | 'MONGODB-X509'
|
363 | | 'MONGODB-CR'
|
364 | | 'SCRAM-SHA-1'
|
365 | | 'SCRAM-SHA-256'
|
366 | | string;
|
367 |
|
368 |
|
369 | compression?: {
|
370 |
|
371 | compressors?: Array<'snappy' | 'zlib'>;
|
372 | };
|
373 | }
|
374 |
|
375 | export interface SSLOptions {
|
376 | |
377 |
|
378 |
|
379 | ciphers?: string;
|
380 | |
381 |
|
382 |
|
383 | ecdhCurve?: string;
|
384 | |
385 |
|
386 |
|
387 | poolSize?: number;
|
388 | |
389 |
|
390 |
|
391 | minSize?: number;
|
392 | |
393 |
|
394 |
|
395 | ssl?: boolean;
|
396 | |
397 |
|
398 |
|
399 | sslValidate?: boolean;
|
400 | |
401 |
|
402 |
|
403 | checkServerIdentity?: boolean | typeof checkServerIdentity;
|
404 | |
405 |
|
406 |
|
407 | sslCA?: ReadonlyArray<Buffer | string>;
|
408 | |
409 |
|
410 |
|
411 | sslCRL?: ReadonlyArray<Buffer | string>;
|
412 | |
413 |
|
414 |
|
415 | sslCert?: Buffer | string;
|
416 | |
417 |
|
418 |
|
419 | sslKey?: Buffer | string;
|
420 | |
421 |
|
422 |
|
423 | sslPass?: Buffer | string;
|
424 | |
425 |
|
426 |
|
427 | servername?: string;
|
428 | }
|
429 |
|
430 | export interface TLSOptions {
|
431 | |
432 |
|
433 |
|
434 |
|
435 | tls?: boolean;
|
436 | |
437 |
|
438 |
|
439 |
|
440 | tlsInsecure?: boolean;
|
441 | |
442 |
|
443 |
|
444 |
|
445 | tlsCAFile?: string;
|
446 | |
447 |
|
448 |
|
449 |
|
450 | tlsCertificateKeyFile?: string;
|
451 | |
452 |
|
453 |
|
454 | tlsCertificateKeyFilePassword?: string;
|
455 | |
456 |
|
457 |
|
458 | tlsAllowInvalidCertificates?: boolean;
|
459 | |
460 |
|
461 |
|
462 |
|
463 | tlsAllowInvalidHostnames?: boolean;
|
464 | }
|
465 |
|
466 | export interface HighAvailabilityOptions {
|
467 | |
468 |
|
469 |
|
470 | ha?: boolean;
|
471 | |
472 |
|
473 |
|
474 | haInterval?: number;
|
475 | |
476 |
|
477 |
|
478 | domainsEnabled?: boolean;
|
479 |
|
480 |
|
481 | readPreference?: ReadPreferenceOrMode;
|
482 |
|
483 | readPreferenceTags?: string[];
|
484 | }
|
485 |
|
486 | export type ReadPreferenceMode = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest';
|
487 | export type ReadPreferenceOrMode = ReadPreference | ReadPreferenceMode;
|
488 | export type ReadPreferenceOptions = {
|
489 | hedge?: { enabled?: boolean };
|
490 | |
491 |
|
492 |
|
493 | maxStalenessSeconds?: number;
|
494 | };
|
495 |
|
496 |
|
497 | export class ReadPreference {
|
498 | constructor(mode: ReadPreferenceMode, tags: object, options?: ReadPreferenceOptions);
|
499 | mode: ReadPreferenceMode;
|
500 | tags: any;
|
501 | static PRIMARY: 'primary';
|
502 | static PRIMARY_PREFERRED: 'primaryPreferred';
|
503 | static SECONDARY: 'secondary';
|
504 | static SECONDARY_PREFERRED: 'secondaryPreferred';
|
505 | static NEAREST: 'nearest';
|
506 | isValid(mode: string): boolean;
|
507 | static isValid(mode: string): boolean;
|
508 | }
|
509 |
|
510 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html */
|
511 | export interface DbCreateOptions extends CommonOptions {
|
512 | |
513 |
|
514 |
|
515 | authSource?: string;
|
516 | |
517 |
|
518 |
|
519 | forceServerObjectId?: boolean;
|
520 | |
521 |
|
522 |
|
523 | native_parser?: boolean;
|
524 | |
525 |
|
526 |
|
527 | serializeFunctions?: boolean;
|
528 | |
529 |
|
530 |
|
531 | ignoreUndefined?: boolean;
|
532 | |
533 |
|
534 |
|
535 | raw?: boolean;
|
536 | |
537 |
|
538 |
|
539 | promoteLongs?: boolean;
|
540 | |
541 |
|
542 |
|
543 | promoteBuffers?: boolean;
|
544 | |
545 |
|
546 |
|
547 | readPreference?: ReadPreferenceOrMode;
|
548 | |
549 |
|
550 |
|
551 | promoteValues?: boolean;
|
552 | |
553 |
|
554 |
|
555 | pkFactory?: object;
|
556 | |
557 |
|
558 |
|
559 | promiseLibrary?: PromiseConstructor;
|
560 | |
561 |
|
562 |
|
563 | readConcern?: ReadConcern | string;
|
564 | |
565 |
|
566 |
|
567 |
|
568 | bufferMaxEntries?: number;
|
569 | }
|
570 |
|
571 | export interface UnifiedTopologyOptions {
|
572 | |
573 |
|
574 |
|
575 | useUnifiedTopology?: boolean;
|
576 |
|
577 | |
578 |
|
579 |
|
580 |
|
581 |
|
582 | localThresholdMS?: number;
|
583 |
|
584 | |
585 |
|
586 |
|
587 |
|
588 |
|
589 | serverSelectionTimeoutMS?: number;
|
590 |
|
591 | |
592 |
|
593 |
|
594 |
|
595 |
|
596 | heartbeatFrequencyMS?: number;
|
597 |
|
598 | |
599 |
|
600 |
|
601 |
|
602 |
|
603 |
|
604 | maxPoolSize?: number;
|
605 |
|
606 | |
607 |
|
608 |
|
609 |
|
610 |
|
611 | minPoolSize?: number;
|
612 |
|
613 | |
614 |
|
615 |
|
616 |
|
617 |
|
618 | maxIdleTimeMS?: number;
|
619 |
|
620 | |
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 | waitQueueTimeoutMS?: number;
|
627 | }
|
628 |
|
629 |
|
630 | export interface SocketOptions {
|
631 | |
632 |
|
633 |
|
634 |
|
635 | autoReconnect?: boolean;
|
636 | |
637 |
|
638 |
|
639 |
|
640 | noDelay?: boolean;
|
641 | |
642 |
|
643 |
|
644 |
|
645 | keepAlive?: boolean;
|
646 | |
647 |
|
648 |
|
649 |
|
650 | keepAliveInitialDelay?: number;
|
651 | |
652 |
|
653 |
|
654 |
|
655 | connectTimeoutMS?: number;
|
656 | |
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 | family?: 4 | 6 | null;
|
664 | |
665 |
|
666 |
|
667 |
|
668 | socketTimeoutMS?: number;
|
669 | }
|
670 |
|
671 |
|
672 | export interface ServerOptions extends SSLOptions {
|
673 | |
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 | reconnectTries?: number;
|
681 | |
682 |
|
683 |
|
684 |
|
685 | reconnectInterval?: number;
|
686 | |
687 |
|
688 |
|
689 | monitoring?: boolean;
|
690 |
|
691 | |
692 |
|
693 |
|
694 |
|
695 | monitorCommands?: boolean;
|
696 |
|
697 | |
698 |
|
699 |
|
700 | socketOptions?: SocketOptions;
|
701 |
|
702 | |
703 |
|
704 |
|
705 |
|
706 | haInterval?: number;
|
707 | |
708 |
|
709 |
|
710 | domainsEnabled?: boolean;
|
711 |
|
712 | |
713 |
|
714 |
|
715 |
|
716 | fsync?: boolean;
|
717 | }
|
718 |
|
719 |
|
720 | export interface MongosOptions extends SSLOptions, HighAvailabilityOptions {
|
721 | |
722 |
|
723 |
|
724 | acceptableLatencyMS?: number;
|
725 |
|
726 | |
727 |
|
728 |
|
729 | socketOptions?: SocketOptions;
|
730 | }
|
731 |
|
732 |
|
733 | export interface ReplSetOptions extends SSLOptions, HighAvailabilityOptions {
|
734 | |
735 |
|
736 |
|
737 | maxStalenessSeconds?: number;
|
738 | |
739 |
|
740 |
|
741 | replicaSet?: string;
|
742 | |
743 |
|
744 |
|
745 | secondaryAcceptableLatencyMS?: number;
|
746 | connectWithNoPrimary?: boolean;
|
747 | socketOptions?: SocketOptions;
|
748 | }
|
749 |
|
750 | export type ProfilingLevel = 'off' | 'slow_only' | 'all';
|
751 |
|
752 |
|
753 | export class Db extends EventEmitter {
|
754 | constructor(databaseName: string, serverConfig: Server | ReplSet | Mongos, options?: DbCreateOptions);
|
755 |
|
756 | serverConfig: Server | ReplSet | Mongos;
|
757 | bufferMaxEntries: number;
|
758 | databaseName: string;
|
759 | options: any;
|
760 | native_parser: boolean;
|
761 | slaveOk: boolean;
|
762 | writeConcern: WriteConcern;
|
763 |
|
764 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser */
|
765 | addUser(username: string, password: string, callback: MongoCallback<any>): void;
|
766 | addUser(username: string, password: string, options?: DbAddUserOptions): Promise<any>;
|
767 | addUser(username: string, password: string, options: DbAddUserOptions, callback: MongoCallback<any>): void;
|
768 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#admin */
|
769 | admin(): Admin;
|
770 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#collection */
|
771 | collection<TSchema = DefaultSchema>(
|
772 | name: string,
|
773 | callback?: MongoCallback<Collection<TSchema>>,
|
774 | ): Collection<TSchema>;
|
775 | collection<TSchema = DefaultSchema>(
|
776 | name: string,
|
777 | options: DbCollectionOptions,
|
778 | callback?: MongoCallback<Collection<TSchema>>,
|
779 | ): Collection<TSchema>;
|
780 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#collections */
|
781 | collections(): Promise<Array<Collection<Default>>>;
|
782 | collections(callback: MongoCallback<Array<Collection<Default>>>): void;
|
783 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#command */
|
784 | command(command: object, callback: MongoCallback<any>): void;
|
785 | command(command: object, options?: { readPreference?: ReadPreferenceOrMode; session?: ClientSession }): Promise<any>;
|
786 | command(
|
787 | command: object,
|
788 | options: { readPreference: ReadPreferenceOrMode; session?: ClientSession },
|
789 | callback: MongoCallback<any>,
|
790 | ): void;
|
791 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createCollection */
|
792 | createCollection<TSchema = DefaultSchema>(name: string, callback: MongoCallback<Collection<TSchema>>): void;
|
793 | createCollection<TSchema = DefaultSchema>(
|
794 | name: string,
|
795 | options?: CollectionCreateOptions,
|
796 | ): Promise<Collection<TSchema>>;
|
797 | createCollection<TSchema = DefaultSchema>(
|
798 | name: string,
|
799 | options: CollectionCreateOptions,
|
800 | callback: MongoCallback<Collection<TSchema>>,
|
801 | ): void;
|
802 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#createIndex */
|
803 | createIndex(name: string, fieldOrSpec: string | object, callback: MongoCallback<any>): void;
|
804 | createIndex(name: string, fieldOrSpec: string | object, options?: IndexOptions): Promise<any>;
|
805 | createIndex(name: string, fieldOrSpec: string | object, options: IndexOptions, callback: MongoCallback<any>): void;
|
806 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#dropCollection */
|
807 | dropCollection(name: string): Promise<boolean>;
|
808 | dropCollection(name: string, callback: MongoCallback<boolean>): void;
|
809 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#dropDatabase */
|
810 | dropDatabase(): Promise<any>;
|
811 | dropDatabase(callback: MongoCallback<any>): void;
|
812 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#executeDbAdminCommand */
|
813 | executeDbAdminCommand(command: object, callback: MongoCallback<any>): void;
|
814 | executeDbAdminCommand(
|
815 | command: object,
|
816 | options?: { readPreference?: ReadPreferenceOrMode; session?: ClientSession },
|
817 | ): Promise<any>;
|
818 | executeDbAdminCommand(
|
819 | command: object,
|
820 | options: { readPreference?: ReadPreferenceOrMode; session?: ClientSession },
|
821 | callback: MongoCallback<any>,
|
822 | ): void;
|
823 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#indexInformation */
|
824 | indexInformation(name: string, callback: MongoCallback<any>): void;
|
825 | indexInformation(name: string, options?: { full?: boolean; readPreference?: ReadPreferenceOrMode }): Promise<any>;
|
826 | indexInformation(
|
827 | name: string,
|
828 | options: { full?: boolean; readPreference?: ReadPreferenceOrMode },
|
829 | callback: MongoCallback<any>,
|
830 | ): void;
|
831 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#listCollections */
|
832 | listCollections(
|
833 | filter?: object,
|
834 | options?: {
|
835 | nameOnly?: boolean;
|
836 | batchSize?: number;
|
837 | readPreference?: ReadPreferenceOrMode;
|
838 | session?: ClientSession;
|
839 | },
|
840 | ): CommandCursor;
|
841 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#profilingInfo */
|
842 | /** @deprecated Query the system.profile collection directly. */
|
843 | profilingInfo(callback: MongoCallback<any>): void;
|
844 | profilingInfo(options?: { session?: ClientSession }): Promise<void>;
|
845 | profilingInfo(options: { session?: ClientSession }, callback: MongoCallback<void>): void;
|
846 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#profilingLevel */
|
847 | profilingLevel(callback: MongoCallback<ProfilingLevel>): void;
|
848 | profilingLevel(options?: { session?: ClientSession }): Promise<ProfilingLevel>;
|
849 | profilingLevel(options: { session?: ClientSession }, callback: MongoCallback<ProfilingLevel>): void;
|
850 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#removeUser */
|
851 | removeUser(username: string, callback: MongoCallback<any>): void;
|
852 | removeUser(username: string, options?: CommonOptions): Promise<any>;
|
853 | removeUser(username: string, options: CommonOptions, callback: MongoCallback<any>): void;
|
854 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#renameCollection */
|
855 | renameCollection<TSchema = DefaultSchema>(
|
856 | fromCollection: string,
|
857 | toCollection: string,
|
858 | callback: MongoCallback<Collection<TSchema>>,
|
859 | ): void;
|
860 | renameCollection<TSchema = DefaultSchema>(
|
861 | fromCollection: string,
|
862 | toCollection: string,
|
863 | options?: { dropTarget?: boolean },
|
864 | ): Promise<Collection<TSchema>>;
|
865 | renameCollection<TSchema = DefaultSchema>(
|
866 | fromCollection: string,
|
867 | toCollection: string,
|
868 | options: { dropTarget?: boolean },
|
869 | callback: MongoCallback<Collection<TSchema>>,
|
870 | ): void;
|
871 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#setProfilingLevel */
|
872 | setProfilingLevel(level: ProfilingLevel, callback: MongoCallback<ProfilingLevel>): void;
|
873 | setProfilingLevel(level: ProfilingLevel, options?: { session?: ClientSession }): Promise<ProfilingLevel>;
|
874 | setProfilingLevel(
|
875 | level: ProfilingLevel,
|
876 | options: { session?: ClientSession },
|
877 | callback: MongoCallback<ProfilingLevel>,
|
878 | ): void;
|
879 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#stats */
|
880 | stats(callback: MongoCallback<any>): void;
|
881 | stats(options?: { scale?: number }): Promise<any>;
|
882 | stats(options: { scale?: number }, callback: MongoCallback<any>): void;
|
883 | /** http://mongodb.github.io/node-mongodb-native/3.3/api/Db.html#watch */
|
884 | watch<TSchema extends object = { _id: ObjectId }>(
|
885 | pipeline?: object[],
|
886 | options?: ChangeStreamOptions & { session?: ClientSession },
|
887 | ): ChangeStream<TSchema>;
|
888 | }
|
889 |
|
890 | export interface CommonOptions extends WriteConcern {
|
891 | session?: ClientSession;
|
892 | }
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 | export class Server extends EventEmitter {
|
899 | constructor(host: string, port: number, options?: ServerOptions);
|
900 |
|
901 | connections(): any[];
|
902 | }
|
903 |
|
904 | /**
|
905 | * @deprecated
|
906 | * @see http://mongodb.github.io/node-mongodb-native/3.1/api/ReplSet.html
|
907 | */
|
908 | export class ReplSet extends EventEmitter {
|
909 | constructor(servers: Server[], options?: ReplSetOptions);
|
910 |
|
911 | connections(): any[];
|
912 | }
|
913 |
|
914 | /**
|
915 | * @deprecated
|
916 | * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Mongos.html
|
917 | */
|
918 | export class Mongos extends EventEmitter {
|
919 | constructor(servers: Server[], options?: MongosOptions);
|
920 |
|
921 | connections(): any[];
|
922 | }
|
923 |
|
924 | /**
|
925 | * @deprecated
|
926 | * @see http://mongodb.github.io/node-mongodb-native/3.1/api/Db.html#addUser
|
927 | */
|
928 | export interface DbAddUserOptions extends CommonOptions {
|
929 | customData?: object;
|
930 | roles?: object[];
|
931 | }
|
932 |
|
933 |
|
934 | export interface CollectionCreateOptions extends CommonOptions {
|
935 | raw?: boolean;
|
936 | pkFactory?: object;
|
937 | readPreference?: ReadPreferenceOrMode;
|
938 | serializeFunctions?: boolean;
|
939 | strict?: boolean;
|
940 | capped?: boolean;
|
941 | autoIndexId?: boolean;
|
942 | size?: number;
|
943 | max?: number;
|
944 | flags?: number;
|
945 | storageEngine?: object;
|
946 | validator?: object;
|
947 | validationLevel?: 'off' | 'strict' | 'moderate';
|
948 | validationAction?: 'error' | 'warn';
|
949 | indexOptionDefaults?: object;
|
950 | viewOn?: string;
|
951 | pipeline?: any[];
|
952 | collation?: CollationDocument;
|
953 | }
|
954 |
|
955 |
|
956 | export interface DbCollectionOptions extends CommonOptions {
|
957 | raw?: boolean;
|
958 | pkFactory?: object;
|
959 | readPreference?: ReadPreferenceOrMode;
|
960 | serializeFunctions?: boolean;
|
961 | strict?: boolean;
|
962 | readConcern?: ReadConcern;
|
963 | }
|
964 |
|
965 |
|
966 | export interface IndexOptions extends CommonOptions {
|
967 | |
968 |
|
969 |
|
970 | unique?: boolean;
|
971 | |
972 |
|
973 |
|
974 | sparse?: boolean;
|
975 | |
976 |
|
977 |
|
978 | background?: boolean;
|
979 | |
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 | dropDups?: boolean;
|
986 | |
987 |
|
988 |
|
989 | min?: number;
|
990 | |
991 |
|
992 |
|
993 | max?: number;
|
994 | |
995 |
|
996 |
|
997 | v?: number;
|
998 | |
999 |
|
1000 |
|
1001 | expireAfterSeconds?: number;
|
1002 | |
1003 |
|
1004 |
|
1005 | name?: string;
|
1006 | |
1007 |
|
1008 |
|
1009 | partialFilterExpression?: any;
|
1010 | collation?: CollationDocument;
|
1011 | default_language?: string;
|
1012 | }
|
1013 |
|
1014 |
|
1015 | export interface Admin {
|
1016 |
|
1017 | addUser(username: string, password: string, callback: MongoCallback<any>): void;
|
1018 | addUser(username: string, password: string, options?: AddUserOptions): Promise<any>;
|
1019 | addUser(username: string, password: string, options: AddUserOptions, callback: MongoCallback<any>): void;
|
1020 |
|
1021 | buildInfo(options?: { session?: ClientSession }): Promise<any>;
|
1022 | buildInfo(options: { session?: ClientSession }, callback: MongoCallback<any>): void;
|
1023 | buildInfo(callback: MongoCallback<any>): void;
|
1024 |
|
1025 | command(command: object, callback: MongoCallback<any>): void;
|
1026 | command(command: object, options?: { readPreference?: ReadPreferenceOrMode; maxTimeMS?: number }): Promise<any>;
|
1027 | command(
|
1028 | command: object,
|
1029 | options: { readPreference?: ReadPreferenceOrMode; maxTimeMS?: number },
|
1030 | callback: MongoCallback<any>,
|
1031 | ): void;
|
1032 |
|
1033 | listDatabases(options?: { nameOnly?: boolean; session?: ClientSession }): Promise<any>;
|
1034 | listDatabases(options: { nameOnly?: boolean; session?: ClientSession }, callback: MongoCallback<any>): void;
|
1035 | listDatabases(callback: MongoCallback<any>): void;
|
1036 |
|
1037 | ping(options?: { session?: ClientSession }): Promise<any>;
|
1038 | ping(options: { session?: ClientSession }, callback: MongoCallback<any>): void;
|
1039 | ping(callback: MongoCallback<any>): void;
|
1040 |
|
1041 | removeUser(username: string, callback: MongoCallback<any>): void;
|
1042 | removeUser(username: string, options?: FSyncOptions): Promise<any>;
|
1043 | removeUser(username: string, options: FSyncOptions, callback: MongoCallback<any>): void;
|
1044 |
|
1045 | replSetGetStatus(options?: { session?: ClientSession }): Promise<any>;
|
1046 | replSetGetStatus(options: { session?: ClientSession }, callback: MongoCallback<any>): void;
|
1047 | replSetGetStatus(callback: MongoCallback<any>): void;
|
1048 |
|
1049 | serverInfo(): Promise<any>;
|
1050 | serverInfo(callback: MongoCallback<any>): void;
|
1051 |
|
1052 | serverStatus(options?: { session?: ClientSession }): Promise<any>;
|
1053 | serverStatus(options: { session?: ClientSession }, callback: MongoCallback<any>): void;
|
1054 | serverStatus(callback: MongoCallback<any>): void;
|
1055 |
|
1056 | validateCollection(collectionNme: string, callback: MongoCallback<any>): void;
|
1057 | validateCollection(collectionNme: string, options?: object): Promise<any>;
|
1058 | validateCollection(collectionNme: string, options: object, callback: MongoCallback<any>): void;
|
1059 | }
|
1060 |
|
1061 |
|
1062 | export interface AddUserOptions extends CommonOptions {
|
1063 | fsync: boolean;
|
1064 | customData?: object;
|
1065 | roles?: object[];
|
1066 | }
|
1067 |
|
1068 |
|
1069 | export interface FSyncOptions extends CommonOptions {
|
1070 | fsync?: boolean;
|
1071 | }
|
1072 |
|
1073 |
|
1074 | type EnhancedOmit<T, K> = string | number extends keyof T
|
1075 | ? T
|
1076 | : Omit<T, K>;
|
1077 |
|
1078 | type ExtractIdType<TSchema> = TSchema extends { _id: infer U }
|
1079 | ? {} extends U
|
1080 | ? Exclude<U, {}>
|
1081 | : unknown extends U
|
1082 | ? ObjectId
|
1083 | : U
|
1084 | : ObjectId;
|
1085 |
|
1086 |
|
1087 | export type OptionalId<TSchema extends { _id?: any }> = ObjectId extends TSchema['_id']
|
1088 | ?
|
1089 | EnhancedOmit<TSchema, '_id'> & { _id?: ExtractIdType<TSchema> }
|
1090 | :
|
1091 | WithId<TSchema>;
|
1092 |
|
1093 |
|
1094 | export type WithId<TSchema> = EnhancedOmit<TSchema, '_id'> & { _id: ExtractIdType<TSchema> };
|
1095 |
|
1096 |
|
1097 | export interface Collection<TSchema extends { [key: string]: any } = DefaultSchema> {
|
1098 | |
1099 |
|
1100 |
|
1101 | collectionName: string;
|
1102 | |
1103 |
|
1104 |
|
1105 | namespace: string;
|
1106 | |
1107 |
|
1108 |
|
1109 | writeConcern: WriteConcern;
|
1110 | |
1111 |
|
1112 |
|
1113 | readConcern: ReadConcern;
|
1114 | |
1115 |
|
1116 |
|
1117 | hint: any;
|
1118 |
|
1119 | aggregate<T = TSchema>(callback: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
1120 | aggregate<T = TSchema>(pipeline: object[], callback: MongoCallback<AggregationCursor<T>>): AggregationCursor<T>;
|
1121 | aggregate<T = TSchema>(
|
1122 | pipeline?: object[],
|
1123 | options?: CollectionAggregationOptions,
|
1124 | callback?: MongoCallback<AggregationCursor<T>>,
|
1125 | ): AggregationCursor<T>;
|
1126 |
|
1127 | bulkWrite(operations: Array<BulkWriteOperation<TSchema>>, callback: MongoCallback<BulkWriteOpResultObject>): void;
|
1128 | bulkWrite(
|
1129 | operations: Array<BulkWriteOperation<TSchema>>,
|
1130 | options?: CollectionBulkWriteOptions,
|
1131 | ): Promise<BulkWriteOpResultObject>;
|
1132 | bulkWrite(
|
1133 | operations: Array<BulkWriteOperation<TSchema>>,
|
1134 | options: CollectionBulkWriteOptions,
|
1135 | callback: MongoCallback<BulkWriteOpResultObject>,
|
1136 | ): void;
|
1137 | |
1138 |
|
1139 |
|
1140 |
|
1141 | count(callback: MongoCallback<number>): void;
|
1142 | count(query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
|
1143 | count(query?: FilterQuery<TSchema>, options?: MongoCountPreferences): Promise<number>;
|
1144 | count(query: FilterQuery<TSchema>, options: MongoCountPreferences, callback: MongoCallback<number>): void;
|
1145 |
|
1146 | countDocuments(callback: MongoCallback<number>): void;
|
1147 | countDocuments(query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
|
1148 | countDocuments(query?: FilterQuery<TSchema>, options?: MongoCountPreferences): Promise<number>;
|
1149 | countDocuments(query: FilterQuery<TSchema>, options: MongoCountPreferences, callback: MongoCallback<number>): void;
|
1150 |
|
1151 | createIndex(fieldOrSpec: string | any, callback: MongoCallback<string>): void;
|
1152 | createIndex(fieldOrSpec: string | any, options?: IndexOptions): Promise<string>;
|
1153 | createIndex(fieldOrSpec: string | any, options: IndexOptions, callback: MongoCallback<string>): void;
|
1154 |
|
1155 | createIndexes(indexSpecs: IndexSpecification[], callback: MongoCallback<any>): void;
|
1156 | createIndexes(indexSpecs: IndexSpecification[], options?: { session?: ClientSession }): Promise<any>;
|
1157 | createIndexes(
|
1158 | indexSpecs: IndexSpecification[],
|
1159 | options: { session?: ClientSession },
|
1160 | callback: MongoCallback<any>,
|
1161 | ): void;
|
1162 |
|
1163 | deleteMany(filter: FilterQuery<TSchema>, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
1164 | deleteMany(filter: FilterQuery<TSchema>, options?: CommonOptions): Promise<DeleteWriteOpResultObject>;
|
1165 | deleteMany(
|
1166 | filter: FilterQuery<TSchema>,
|
1167 | options: CommonOptions,
|
1168 | callback: MongoCallback<DeleteWriteOpResultObject>,
|
1169 | ): void;
|
1170 |
|
1171 | deleteOne(filter: FilterQuery<TSchema>, callback: MongoCallback<DeleteWriteOpResultObject>): void;
|
1172 | deleteOne(
|
1173 | filter: FilterQuery<TSchema>,
|
1174 | options?: CommonOptions & { bypassDocumentValidation?: boolean },
|
1175 | ): Promise<DeleteWriteOpResultObject>;
|
1176 | deleteOne(
|
1177 | filter: FilterQuery<TSchema>,
|
1178 | options: CommonOptions & { bypassDocumentValidation?: boolean },
|
1179 | callback: MongoCallback<DeleteWriteOpResultObject>,
|
1180 | ): void;
|
1181 |
|
1182 | distinct<Key extends keyof WithId<TSchema>>(
|
1183 | key: Key,
|
1184 | callback: MongoCallback<Array<FlattenIfArray<WithId<TSchema>[Key]>>>,
|
1185 | ): void;
|
1186 | distinct<Key extends keyof WithId<TSchema>>(
|
1187 | key: Key,
|
1188 | query: FilterQuery<TSchema>,
|
1189 | callback: MongoCallback<Array<FlattenIfArray<WithId<TSchema>[Key]>>>,
|
1190 | ): void;
|
1191 | distinct<Key extends keyof WithId<TSchema>>(
|
1192 | key: Key,
|
1193 | query?: FilterQuery<TSchema>,
|
1194 | options?: MongoDistinctPreferences,
|
1195 | ): Promise<Array<FlattenIfArray<WithId<TSchema>[Key]>>>;
|
1196 | distinct<Key extends keyof WithId<TSchema>>(
|
1197 | key: Key,
|
1198 | query: FilterQuery<TSchema>,
|
1199 | options: MongoDistinctPreferences,
|
1200 | callback: MongoCallback<Array<FlattenIfArray<WithId<TSchema>[Key]>>>,
|
1201 | ): void;
|
1202 | distinct(key: string, callback: MongoCallback<any[]>): void;
|
1203 | distinct(key: string, query: FilterQuery<TSchema>, callback: MongoCallback<any[]>): void;
|
1204 | distinct(key: string, query?: FilterQuery<TSchema>, options?: MongoDistinctPreferences): Promise<any[]>;
|
1205 | distinct(
|
1206 | key: string,
|
1207 | query: FilterQuery<TSchema>,
|
1208 | options: MongoDistinctPreferences,
|
1209 | callback: MongoCallback<any[]>,
|
1210 | ): void;
|
1211 |
|
1212 | drop(options?: { session: ClientSession }): Promise<any>;
|
1213 | drop(callback: MongoCallback<any>): void;
|
1214 | drop(options: { session: ClientSession }, callback: MongoCallback<any>): void;
|
1215 |
|
1216 | dropIndex(indexName: string, callback: MongoCallback<any>): void;
|
1217 | dropIndex(indexName: string, options?: CommonOptions & { maxTimeMS?: number }): Promise<any>;
|
1218 | dropIndex(indexName: string, options: CommonOptions & { maxTimeMS?: number }, callback: MongoCallback<any>): void;
|
1219 |
|
1220 | dropIndexes(options?: { session?: ClientSession; maxTimeMS?: number }): Promise<any>;
|
1221 | dropIndexes(callback?: MongoCallback<any>): void;
|
1222 | dropIndexes(options: { session?: ClientSession; maxTimeMS?: number }, callback: MongoCallback<any>): void;
|
1223 |
|
1224 | estimatedDocumentCount(callback: MongoCallback<number>): void;
|
1225 | estimatedDocumentCount(query: FilterQuery<TSchema>, callback: MongoCallback<number>): void;
|
1226 | estimatedDocumentCount(query?: FilterQuery<TSchema>, options?: MongoCountPreferences): Promise<number>;
|
1227 | estimatedDocumentCount(
|
1228 | query: FilterQuery<TSchema>,
|
1229 | options: MongoCountPreferences,
|
1230 | callback: MongoCallback<number>,
|
1231 | ): void;
|
1232 |
|
1233 | find<T = TSchema>(query?: FilterQuery<TSchema>): Cursor<T>;
|
1234 | find<T = TSchema>(
|
1235 | query: FilterQuery<TSchema>,
|
1236 | options?: FindOneOptions<T extends TSchema ? TSchema : T>,
|
1237 | ): Cursor<T>;
|
1238 |
|
1239 | findOne<T = TSchema>(
|
1240 | filter: FilterQuery<TSchema>,
|
1241 | callback: MongoCallback<T extends TSchema ? TSchema : T | null>,
|
1242 | ): void;
|
1243 | findOne<T = TSchema>(
|
1244 | filter: FilterQuery<TSchema>,
|
1245 | options?: FindOneOptions<T extends TSchema ? TSchema : T>,
|
1246 | ): Promise<T | null>;
|
1247 | findOne<T = TSchema>(
|
1248 | filter: FilterQuery<TSchema>,
|
1249 | options: FindOneOptions<T extends TSchema ? TSchema : T>,
|
1250 | callback: MongoCallback<T extends TSchema ? TSchema : T | null>,
|
1251 | ): void;
|
1252 |
|
1253 | findOneAndDelete(
|
1254 | filter: FilterQuery<TSchema>,
|
1255 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1256 | ): void;
|
1257 | findOneAndDelete(
|
1258 | filter: FilterQuery<TSchema>,
|
1259 | options?: FindOneAndDeleteOption<TSchema>,
|
1260 | ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
1261 | findOneAndDelete(
|
1262 | filter: FilterQuery<TSchema>,
|
1263 | options: FindOneAndDeleteOption<TSchema>,
|
1264 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1265 | ): void;
|
1266 |
|
1267 | findOneAndReplace(
|
1268 | filter: FilterQuery<TSchema>,
|
1269 | replacement: object,
|
1270 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1271 | ): void;
|
1272 | findOneAndReplace(
|
1273 | filter: FilterQuery<TSchema>,
|
1274 | replacement: object,
|
1275 | options?: FindOneAndReplaceOption<TSchema>,
|
1276 | ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
1277 | findOneAndReplace(
|
1278 | filter: FilterQuery<TSchema>,
|
1279 | replacement: object,
|
1280 | options: FindOneAndReplaceOption<TSchema>,
|
1281 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1282 | ): void;
|
1283 |
|
1284 | findOneAndUpdate(
|
1285 | filter: FilterQuery<TSchema>,
|
1286 | update: UpdateQuery<TSchema> | TSchema,
|
1287 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1288 | ): void;
|
1289 | findOneAndUpdate(
|
1290 | filter: FilterQuery<TSchema>,
|
1291 | update: UpdateQuery<TSchema> | TSchema,
|
1292 | options?: FindOneAndUpdateOption<TSchema>,
|
1293 | ): Promise<FindAndModifyWriteOpResultObject<TSchema>>;
|
1294 | findOneAndUpdate(
|
1295 | filter: FilterQuery<TSchema>,
|
1296 | update: UpdateQuery<TSchema> | TSchema,
|
1297 | options: FindOneAndUpdateOption<TSchema>,
|
1298 | callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>,
|
1299 | ): void;
|
1300 |
|
1301 | geoHaystackSearch(x: number, y: number, callback: MongoCallback<any>): void;
|
1302 | geoHaystackSearch(x: number, y: number, options?: GeoHaystackSearchOptions): Promise<any>;
|
1303 | geoHaystackSearch(x: number, y: number, options: GeoHaystackSearchOptions, callback: MongoCallback<any>): void;
|
1304 |
|
1305 |
|
1306 | group(
|
1307 | keys: object | any[] | Function | Code,
|
1308 | condition: object,
|
1309 | initial: object,
|
1310 | reduce: Function | Code,
|
1311 | finalize: Function | Code,
|
1312 | command: boolean,
|
1313 | callback: MongoCallback<any>,
|
1314 | ): void;
|
1315 |
|
1316 | group(
|
1317 | keys: object | any[] | Function | Code,
|
1318 | condition: object,
|
1319 | initial: object,
|
1320 | reduce: Function | Code,
|
1321 | finalize: Function | Code,
|
1322 | command: boolean,
|
1323 | options?: { readPreference?: ReadPreferenceOrMode; session?: ClientSession },
|
1324 | ): Promise<any>;
|
1325 |
|
1326 | group(
|
1327 | keys: object | any[] | Function | Code,
|
1328 | condition: object,
|
1329 | initial: object,
|
1330 | reduce: Function | Code,
|
1331 | finalize: Function | Code,
|
1332 | command: boolean,
|
1333 | options: {
|
1334 | readPreference?: ReadPreferenceOrMode;
|
1335 | session?: ClientSession;
|
1336 | },
|
1337 | callback: MongoCallback<any>,
|
1338 | ): void;
|
1339 |
|
1340 | indexes(options?: { session: ClientSession }): Promise<any>;
|
1341 | indexes(callback: MongoCallback<any>): void;
|
1342 | indexes(options: { session?: ClientSession }, callback: MongoCallback<any>): void;
|
1343 |
|
1344 | indexExists(indexes: string | string[], callback: MongoCallback<boolean>): void;
|
1345 | indexExists(indexes: string | string[], options?: { session: ClientSession }): Promise<boolean>;
|
1346 | indexExists(
|
1347 | indexes: string | string[],
|
1348 | options: { session: ClientSession },
|
1349 | callback: MongoCallback<boolean>,
|
1350 | ): void;
|
1351 |
|
1352 | indexInformation(callback: MongoCallback<any>): void;
|
1353 | indexInformation(options?: { full: boolean; session: ClientSession }): Promise<any>;
|
1354 | indexInformation(options: { full: boolean; session: ClientSession }, callback: MongoCallback<any>): void;
|
1355 |
|
1356 | initializeOrderedBulkOp(options?: CommonOptions): OrderedBulkOperation;
|
1357 |
|
1358 | initializeUnorderedBulkOp(options?: CommonOptions): UnorderedBulkOperation;
|
1359 |
|
1360 |
|
1361 | insert(docs: OptionalId<TSchema>, callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
|
1362 |
|
1363 | insert(
|
1364 | docs: OptionalId<TSchema>,
|
1365 | options?: CollectionInsertOneOptions,
|
1366 | ): Promise<InsertWriteOpResult<WithId<TSchema>>>;
|
1367 |
|
1368 | insert(
|
1369 | docs: OptionalId<TSchema>,
|
1370 | options: CollectionInsertOneOptions,
|
1371 | callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>,
|
1372 | ): void;
|
1373 |
|
1374 | insertMany(docs: Array<OptionalId<TSchema>>, callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>): void;
|
1375 | insertMany(
|
1376 | docs: Array<OptionalId<TSchema>>,
|
1377 | options?: CollectionInsertManyOptions,
|
1378 | ): Promise<InsertWriteOpResult<WithId<TSchema>>>;
|
1379 | insertMany(
|
1380 | docs: Array<OptionalId<TSchema>>,
|
1381 | options: CollectionInsertManyOptions,
|
1382 | callback: MongoCallback<InsertWriteOpResult<WithId<TSchema>>>,
|
1383 | ): void;
|
1384 |
|
1385 | insertOne(docs: OptionalId<TSchema>, callback: MongoCallback<InsertOneWriteOpResult<WithId<TSchema>>>): void;
|
1386 | insertOne(
|
1387 | docs: OptionalId<TSchema>,
|
1388 | options?: CollectionInsertOneOptions,
|
1389 | ): Promise<InsertOneWriteOpResult<WithId<TSchema>>>;
|
1390 | insertOne(
|
1391 | docs: OptionalId<TSchema>,
|
1392 | options: CollectionInsertOneOptions,
|
1393 | callback: MongoCallback<InsertOneWriteOpResult<WithId<TSchema>>>,
|
1394 | ): void;
|
1395 |
|
1396 | isCapped(options?: { session: ClientSession }): Promise<any>;
|
1397 | isCapped(callback: MongoCallback<any>): void;
|
1398 | isCapped(options: { session: ClientSession }, callback: MongoCallback<any>): void;
|
1399 |
|
1400 | listIndexes(options?: {
|
1401 | batchSize?: number;
|
1402 | readPreference?: ReadPreferenceOrMode;
|
1403 | session?: ClientSession;
|
1404 | }): CommandCursor;
|
1405 |
|
1406 | mapReduce<TKey, TValue>(
|
1407 | map: CollectionMapFunction<TSchema> | string,
|
1408 | reduce: CollectionReduceFunction<TKey, TValue> | string,
|
1409 | callback: MongoCallback<any>,
|
1410 | ): void;
|
1411 | mapReduce<TKey, TValue>(
|
1412 | map: CollectionMapFunction<TSchema> | string,
|
1413 | reduce: CollectionReduceFunction<TKey, TValue> | string,
|
1414 | options?: MapReduceOptions,
|
1415 | ): Promise<any>;
|
1416 | mapReduce<TKey, TValue>(
|
1417 | map: CollectionMapFunction<TSchema> | string,
|
1418 | reduce: CollectionReduceFunction<TKey, TValue> | string,
|
1419 | options: MapReduceOptions,
|
1420 | callback: MongoCallback<any>,
|
1421 | ): void;
|
1422 |
|
1423 | options(options?: { session: ClientSession }): Promise<any>;
|
1424 | options(callback: MongoCallback<any>): void;
|
1425 | options(options: { session: ClientSession }, callback: MongoCallback<any>): void;
|
1426 |
|
1427 | parallelCollectionScan(callback: MongoCallback<Array<Cursor<any>>>): void;
|
1428 | parallelCollectionScan(options?: ParallelCollectionScanOptions): Promise<Array<Cursor<any>>>;
|
1429 | parallelCollectionScan(options: ParallelCollectionScanOptions, callback: MongoCallback<Array<Cursor<any>>>): void;
|
1430 |
|
1431 | reIndex(options?: { session: ClientSession }): Promise<any>;
|
1432 | reIndex(callback: MongoCallback<any>): void;
|
1433 | reIndex(options: { session: ClientSession }, callback: MongoCallback<any>): void;
|
1434 |
|
1435 |
|
1436 | remove(selector: object, callback: MongoCallback<WriteOpResult>): void;
|
1437 |
|
1438 | remove(selector: object, options?: CommonOptions & { single?: boolean }): Promise<WriteOpResult>;
|
1439 |
|
1440 | remove(
|
1441 | selector: object,
|
1442 | options?: CommonOptions & { single?: boolean },
|
1443 | callback?: MongoCallback<WriteOpResult>,
|
1444 | ): void;
|
1445 |
|
1446 | rename(newName: string, callback: MongoCallback<Collection<TSchema>>): void;
|
1447 | rename(newName: string, options?: { dropTarget?: boolean; session?: ClientSession }): Promise<Collection<TSchema>>;
|
1448 | rename(
|
1449 | newName: string,
|
1450 | options: { dropTarget?: boolean; session?: ClientSession },
|
1451 | callback: MongoCallback<Collection<TSchema>>,
|
1452 | ): void;
|
1453 |
|
1454 | replaceOne(filter: FilterQuery<TSchema>, doc: TSchema, callback: MongoCallback<ReplaceWriteOpResult>): void;
|
1455 | replaceOne(filter: FilterQuery<TSchema>, doc: TSchema, options?: ReplaceOneOptions): Promise<ReplaceWriteOpResult>;
|
1456 | replaceOne(
|
1457 | filter: FilterQuery<TSchema>,
|
1458 | doc: TSchema,
|
1459 | options: ReplaceOneOptions,
|
1460 | callback: MongoCallback<ReplaceWriteOpResult>,
|
1461 | ): void;
|
1462 |
|
1463 |
|
1464 | save(doc: TSchema, callback: MongoCallback<WriteOpResult>): void;
|
1465 |
|
1466 | save(doc: TSchema, options?: CommonOptions): Promise<WriteOpResult>;
|
1467 |
|
1468 | save(doc: TSchema, options: CommonOptions, callback: MongoCallback<WriteOpResult>): void;
|
1469 |
|
1470 | stats(callback: MongoCallback<CollStats>): void;
|
1471 | stats(options?: { scale: number; session?: ClientSession }): Promise<CollStats>;
|
1472 | stats(options: { scale: number; session?: ClientSession }, callback: MongoCallback<CollStats>): void;
|
1473 |
|
1474 |
|
1475 | update(
|
1476 | filter: FilterQuery<TSchema>,
|
1477 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1478 | callback: MongoCallback<WriteOpResult>,
|
1479 | ): void;
|
1480 |
|
1481 | update(
|
1482 | filter: FilterQuery<TSchema>,
|
1483 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1484 | options?: UpdateOneOptions & { multi?: boolean },
|
1485 | ): Promise<WriteOpResult>;
|
1486 |
|
1487 | update(
|
1488 | filter: FilterQuery<TSchema>,
|
1489 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1490 | options: UpdateOneOptions & { multi?: boolean },
|
1491 | callback: MongoCallback<WriteOpResult>,
|
1492 | ): void;
|
1493 |
|
1494 | updateMany(
|
1495 | filter: FilterQuery<TSchema>,
|
1496 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1497 | callback: MongoCallback<UpdateWriteOpResult>,
|
1498 | ): void;
|
1499 | updateMany(
|
1500 | filter: FilterQuery<TSchema>,
|
1501 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1502 | options?: UpdateManyOptions,
|
1503 | ): Promise<UpdateWriteOpResult>;
|
1504 | updateMany(
|
1505 | filter: FilterQuery<TSchema>,
|
1506 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1507 | options: UpdateManyOptions,
|
1508 | callback: MongoCallback<UpdateWriteOpResult>,
|
1509 | ): void;
|
1510 |
|
1511 | updateOne(
|
1512 | filter: FilterQuery<TSchema>,
|
1513 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1514 | callback: MongoCallback<UpdateWriteOpResult>,
|
1515 | ): void;
|
1516 | updateOne(
|
1517 | filter: FilterQuery<TSchema>,
|
1518 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1519 | options?: UpdateOneOptions,
|
1520 | ): Promise<UpdateWriteOpResult>;
|
1521 | updateOne(
|
1522 | filter: FilterQuery<TSchema>,
|
1523 | update: UpdateQuery<TSchema> | Partial<TSchema>,
|
1524 | options: UpdateOneOptions,
|
1525 | callback: MongoCallback<UpdateWriteOpResult>,
|
1526 | ): void;
|
1527 | |
1528 |
|
1529 |
|
1530 |
|
1531 |
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 | watch<T = TSchema>(
|
1537 | pipeline?: object[],
|
1538 | options?: ChangeStreamOptions & { session?: ClientSession },
|
1539 | ): ChangeStream<T>;
|
1540 | |
1541 |
|
1542 |
|
1543 |
|
1544 | watch<T = TSchema>(options?: ChangeStreamOptions & { session?: ClientSession }): ChangeStream<T>;
|
1545 | }
|
1546 |
|
1547 |
|
1548 | type KeysOfAType<TSchema, Type> = {
|
1549 | [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? key : never;
|
1550 | }[keyof TSchema];
|
1551 | type KeysOfOtherType<TSchema, Type> = {
|
1552 | [key in keyof TSchema]: NonNullable<TSchema[key]> extends Type ? never : key;
|
1553 | }[keyof TSchema];
|
1554 |
|
1555 | type AcceptedFields<TSchema, FieldType, AssignableType> = {
|
1556 | readonly [key in KeysOfAType<TSchema, FieldType>]?: AssignableType;
|
1557 | };
|
1558 |
|
1559 |
|
1560 | type NotAcceptedFields<TSchema, FieldType> = {
|
1561 | readonly [key in KeysOfOtherType<TSchema, FieldType>]?: never;
|
1562 | };
|
1563 |
|
1564 | type DotAndArrayNotation<AssignableType> = {
|
1565 | readonly [key: string]: AssignableType;
|
1566 | };
|
1567 |
|
1568 | type ReadonlyPartial<TSchema> = {
|
1569 | readonly [key in keyof TSchema]?: TSchema[key];
|
1570 | };
|
1571 |
|
1572 | export type OnlyFieldsOfType<TSchema, FieldType = any, AssignableType = FieldType> = AcceptedFields<
|
1573 | TSchema,
|
1574 | FieldType,
|
1575 | AssignableType
|
1576 | > &
|
1577 | NotAcceptedFields<TSchema, FieldType> &
|
1578 | DotAndArrayNotation<AssignableType>;
|
1579 |
|
1580 | export type MatchKeysAndValues<TSchema> = ReadonlyPartial<TSchema> & DotAndArrayNotation<any>;
|
1581 |
|
1582 | type Unpacked<Type> = Type extends ReadonlyArray<infer Element> ? Element : Type;
|
1583 |
|
1584 | type UpdateOptionalId<T> = T extends { _id?: any } ? OptionalId<T> : T;
|
1585 |
|
1586 | export type SortValues = -1 | 1;
|
1587 |
|
1588 |
|
1589 | export type MetaSortOperators = 'textScore' | 'indexKey';
|
1590 |
|
1591 | export type MetaProjectionOperators =
|
1592 | | MetaSortOperators
|
1593 |
|
1594 | | 'searchScore'
|
1595 |
|
1596 | | 'searchHighlights';
|
1597 |
|
1598 | export type SchemaMember<T, V> = { [P in keyof T]?: V } | { [key: string]: V };
|
1599 |
|
1600 | export type SortOptionObject<T> = SchemaMember<T, number | { $meta?: MetaSortOperators }>;
|
1601 |
|
1602 | export type AddToSetOperators<Type> = {
|
1603 | $each: Type;
|
1604 | };
|
1605 |
|
1606 | export type ArrayOperator<Type> = {
|
1607 | $each: Type;
|
1608 | $slice?: number;
|
1609 | $position?: number;
|
1610 | $sort?: SortValues | Record<string, SortValues>;
|
1611 | };
|
1612 |
|
1613 | export type SetFields<TSchema> = ({
|
1614 | readonly [key in KeysOfAType<TSchema, ReadonlyArray<any> | undefined>]?:
|
1615 | | UpdateOptionalId<Unpacked<TSchema[key]>>
|
1616 | | AddToSetOperators<Array<UpdateOptionalId<Unpacked<TSchema[key]>>>>;
|
1617 | } &
|
1618 | NotAcceptedFields<TSchema, ReadonlyArray<any> | undefined>) & {
|
1619 | readonly [key: string]: AddToSetOperators<any> | any;
|
1620 | };
|
1621 |
|
1622 | export type PushOperator<TSchema> = ({
|
1623 | readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?:
|
1624 | | UpdateOptionalId<Unpacked<TSchema[key]>>
|
1625 | | ArrayOperator<Array<UpdateOptionalId<Unpacked<TSchema[key]>>>>;
|
1626 | } &
|
1627 | NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
1628 | readonly [key: string]: ArrayOperator<any> | any;
|
1629 | };
|
1630 |
|
1631 | export type PullOperator<TSchema> = ({
|
1632 | readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?:
|
1633 | | Partial<Unpacked<TSchema[key]>>
|
1634 | | ObjectQuerySelector<Unpacked<TSchema[key]>>;
|
1635 | } &
|
1636 | NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
1637 | readonly [key: string]: QuerySelector<any> | any;
|
1638 | };
|
1639 |
|
1640 | export type PullAllOperator<TSchema> = ({
|
1641 | readonly [key in KeysOfAType<TSchema, ReadonlyArray<any>>]?: TSchema[key];
|
1642 | } &
|
1643 | NotAcceptedFields<TSchema, ReadonlyArray<any>>) & {
|
1644 | readonly [key: string]: any[];
|
1645 | };
|
1646 |
|
1647 |
|
1648 | export type UpdateQuery<TSchema> = {
|
1649 |
|
1650 | $currentDate?: OnlyFieldsOfType<TSchema, Date, true | { $type: 'date' | 'timestamp' }>;
|
1651 | $inc?: OnlyFieldsOfType<TSchema, NumericTypes | undefined>;
|
1652 | $min?: MatchKeysAndValues<TSchema>;
|
1653 | $max?: MatchKeysAndValues<TSchema>;
|
1654 | $mul?: OnlyFieldsOfType<TSchema, NumericTypes | undefined>;
|
1655 | $rename?: { [key: string]: string };
|
1656 | $set?: MatchKeysAndValues<TSchema>;
|
1657 | $setOnInsert?: MatchKeysAndValues<TSchema>;
|
1658 | $unset?: OnlyFieldsOfType<TSchema, any, '' | 1 | true>;
|
1659 |
|
1660 |
|
1661 | $addToSet?: SetFields<TSchema>;
|
1662 | $pop?: OnlyFieldsOfType<TSchema, ReadonlyArray<any>, 1 | -1>;
|
1663 | $pull?: PullOperator<TSchema>;
|
1664 | $push?: PushOperator<TSchema>;
|
1665 | $pullAll?: PullAllOperator<TSchema>;
|
1666 |
|
1667 |
|
1668 | $bit?: {
|
1669 | [key: string]: { [key in 'and' | 'or' | 'xor']?: number };
|
1670 | };
|
1671 | };
|
1672 |
|
1673 |
|
1674 | export enum BSONType {
|
1675 | Double = 1,
|
1676 | String,
|
1677 | Object,
|
1678 | Array,
|
1679 | BinData,
|
1680 |
|
1681 | Undefined,
|
1682 | ObjectId,
|
1683 | Boolean,
|
1684 | Date,
|
1685 | Null,
|
1686 | Regex,
|
1687 |
|
1688 | DBPointer,
|
1689 | JavaScript,
|
1690 |
|
1691 | Symbol,
|
1692 | JavaScriptWithScope,
|
1693 | Int,
|
1694 | Timestamp,
|
1695 | Long,
|
1696 | Decimal,
|
1697 | MinKey = -1,
|
1698 | MaxKey = 127,
|
1699 | }
|
1700 |
|
1701 | type BSONTypeAlias =
|
1702 | | 'number'
|
1703 | | 'double'
|
1704 | | 'string'
|
1705 | | 'object'
|
1706 | | 'array'
|
1707 | | 'binData'
|
1708 | | 'undefined'
|
1709 | | 'objectId'
|
1710 | | 'bool'
|
1711 | | 'date'
|
1712 | | 'null'
|
1713 | | 'regex'
|
1714 | | 'dbPointer'
|
1715 | | 'javascript'
|
1716 | | 'symbol'
|
1717 | | 'javascriptWithScope'
|
1718 | | 'int'
|
1719 | | 'timestamp'
|
1720 | | 'long'
|
1721 | | 'decimal'
|
1722 | | 'minKey'
|
1723 | | 'maxKey';
|
1724 |
|
1725 |
|
1726 | type BitwiseQuery =
|
1727 | | number
|
1728 | | Binary
|
1729 | | number[];
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 | type RegExpForString<T> = T extends string ? RegExp | T : T;
|
1735 | type MongoAltQuery<T> = T extends ReadonlyArray<infer U> ? T | RegExpForString<U> : RegExpForString<T>;
|
1736 |
|
1737 |
|
1738 | export type QuerySelector<T> = {
|
1739 |
|
1740 | $eq?: T;
|
1741 | $gt?: T;
|
1742 | $gte?: T;
|
1743 | $in?: T[];
|
1744 | $lt?: T;
|
1745 | $lte?: T;
|
1746 | $ne?: T;
|
1747 | $nin?: T[];
|
1748 |
|
1749 | $not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>;
|
1750 |
|
1751 | |
1752 |
|
1753 |
|
1754 |
|
1755 | $exists?: boolean;
|
1756 | $type?: BSONType | BSONTypeAlias;
|
1757 |
|
1758 | $expr?: any;
|
1759 | $jsonSchema?: any;
|
1760 | $mod?: T extends number ? [number, number] : never;
|
1761 | $regex?: T extends string ? RegExp | string : never;
|
1762 | $options?: T extends string ? string : never;
|
1763 |
|
1764 |
|
1765 | $geoIntersects?: { $geometry: object };
|
1766 | $geoWithin?: object;
|
1767 | $near?: object;
|
1768 | $nearSphere?: object;
|
1769 | $maxDistance?: number;
|
1770 |
|
1771 |
|
1772 | $all?: T extends ReadonlyArray<infer U> ? any[] : never;
|
1773 | $elemMatch?: T extends ReadonlyArray<infer U> ? object : never;
|
1774 | $size?: T extends ReadonlyArray<infer U> ? number : never;
|
1775 |
|
1776 | $bitsAllClear?: BitwiseQuery;
|
1777 | $bitsAllSet?: BitwiseQuery;
|
1778 | $bitsAnyClear?: BitwiseQuery;
|
1779 | $bitsAnySet?: BitwiseQuery;
|
1780 | };
|
1781 |
|
1782 | export type RootQuerySelector<T> = {
|
1783 |
|
1784 | $and?: Array<FilterQuery<T>>;
|
1785 |
|
1786 | $nor?: Array<FilterQuery<T>>;
|
1787 |
|
1788 | $or?: Array<FilterQuery<T>>;
|
1789 |
|
1790 | $text?: {
|
1791 | $search: string;
|
1792 | $language?: string;
|
1793 | $caseSensitive?: boolean;
|
1794 | $diacraticSensitive?: boolean;
|
1795 | };
|
1796 |
|
1797 | $where?: string | Function;
|
1798 |
|
1799 | $comment?: string;
|
1800 |
|
1801 |
|
1802 | [key: string]: any;
|
1803 | };
|
1804 |
|
1805 | export type ObjectQuerySelector<T> = T extends object ? { [key in keyof T]?: QuerySelector<T[key]> } : QuerySelector<T>;
|
1806 |
|
1807 | export type Condition<T> = MongoAltQuery<T> | QuerySelector<MongoAltQuery<T>>;
|
1808 |
|
1809 | export type FilterQuery<T> = {
|
1810 | [P in keyof T]?: Condition<T[P]>;
|
1811 | } &
|
1812 | RootQuerySelector<T>;
|
1813 |
|
1814 |
|
1815 | export type BulkWriteInsertOneOperation<TSchema> = {
|
1816 | insertOne: {
|
1817 | document: OptionalId<TSchema>;
|
1818 | };
|
1819 | };
|
1820 |
|
1821 |
|
1822 | export type BulkWriteUpdateOperation<TSchema> = {
|
1823 | arrayFilters?: object[];
|
1824 | collation?: object;
|
1825 | hint?: string | object;
|
1826 | filter: FilterQuery<TSchema>;
|
1827 | update: UpdateQuery<TSchema>;
|
1828 | upsert?: boolean;
|
1829 | };
|
1830 | export type BulkWriteUpdateOneOperation<TSchema> = {
|
1831 | updateOne: BulkWriteUpdateOperation<TSchema>;
|
1832 | };
|
1833 | export type BulkWriteUpdateManyOperation<TSchema> = {
|
1834 | updateMany: BulkWriteUpdateOperation<TSchema>;
|
1835 | };
|
1836 |
|
1837 |
|
1838 | export type BulkWriteReplaceOneOperation<TSchema> = {
|
1839 | replaceOne: {
|
1840 | collation?: object;
|
1841 | hint?: string | object;
|
1842 | filter: FilterQuery<TSchema>;
|
1843 | replacement: TSchema;
|
1844 | upsert?: boolean;
|
1845 | };
|
1846 | };
|
1847 |
|
1848 |
|
1849 | export type BulkWriteDeleteOperation<TSchema> = {
|
1850 | collation?: object;
|
1851 | filter: FilterQuery<TSchema>;
|
1852 | };
|
1853 | export type BulkWriteDeleteOneOperation<TSchema> = {
|
1854 | deleteOne: BulkWriteDeleteOperation<TSchema>;
|
1855 | };
|
1856 | export type BulkWriteDeleteManyOperation<TSchema> = {
|
1857 | deleteMany: BulkWriteDeleteOperation<TSchema>;
|
1858 | };
|
1859 |
|
1860 |
|
1861 | export type BulkWriteOperation<TSchema> =
|
1862 | | BulkWriteInsertOneOperation<TSchema>
|
1863 | | BulkWriteUpdateOneOperation<TSchema>
|
1864 | | BulkWriteUpdateManyOperation<TSchema>
|
1865 | | BulkWriteReplaceOneOperation<TSchema>
|
1866 | | BulkWriteDeleteOneOperation<TSchema>
|
1867 | | BulkWriteDeleteManyOperation<TSchema>;
|
1868 |
|
1869 |
|
1870 | export interface CollStats {
|
1871 | |
1872 |
|
1873 |
|
1874 | ns: string;
|
1875 | |
1876 |
|
1877 |
|
1878 | count: number;
|
1879 | |
1880 |
|
1881 |
|
1882 | size: number;
|
1883 | |
1884 |
|
1885 |
|
1886 | avgObjSize: number;
|
1887 | |
1888 |
|
1889 |
|
1890 | storageSize: number;
|
1891 | |
1892 |
|
1893 |
|
1894 | numExtents: number;
|
1895 | |
1896 |
|
1897 |
|
1898 | nindexes: number;
|
1899 | |
1900 |
|
1901 |
|
1902 | lastExtentSize: number;
|
1903 | |
1904 |
|
1905 |
|
1906 | paddingFactor: number;
|
1907 | |
1908 |
|
1909 |
|
1910 | userFlags?: number;
|
1911 | |
1912 |
|
1913 |
|
1914 | totalIndexSize: number;
|
1915 | |
1916 |
|
1917 |
|
1918 | indexSizes: {
|
1919 | _id_: number;
|
1920 | [index: string]: number;
|
1921 | };
|
1922 | |
1923 |
|
1924 |
|
1925 | capped: boolean;
|
1926 | |
1927 |
|
1928 |
|
1929 | max: number;
|
1930 | |
1931 |
|
1932 |
|
1933 | maxSize: number;
|
1934 | wiredTiger?: WiredTigerData;
|
1935 | indexDetails?: any;
|
1936 | ok: number;
|
1937 | }
|
1938 |
|
1939 | export interface WiredTigerData {
|
1940 | LSM: {
|
1941 | 'bloom filter false positives': number;
|
1942 | 'bloom filter hits': number;
|
1943 | 'bloom filter misses': number;
|
1944 | 'bloom filter pages evicted from cache': number;
|
1945 | 'bloom filter pages read into cache': number;
|
1946 | 'bloom filters in the LSM tree': number;
|
1947 | 'chunks in the LSM tree': number;
|
1948 | 'highest merge generation in the LSM tree': number;
|
1949 | 'queries that could have benefited from a Bloom filter that did not exist': number;
|
1950 | 'sleep for LSM checkpoint throttle': number;
|
1951 | 'sleep for LSM merge throttle': number;
|
1952 | 'total size of bloom filters': number;
|
1953 | };
|
1954 | 'block-manager': {
|
1955 | 'allocations requiring file extension': number;
|
1956 | 'blocks allocated': number;
|
1957 | 'blocks freed': number;
|
1958 | 'checkpoint size': number;
|
1959 | 'file allocation unit size': number;
|
1960 | 'file bytes available for reuse': number;
|
1961 | 'file magic number': number;
|
1962 | 'file major version number': number;
|
1963 | 'file size in bytes': number;
|
1964 | 'minor version number': number;
|
1965 | };
|
1966 | btree: {
|
1967 | 'btree checkpoint generation': number;
|
1968 | 'column-store fixed-size leaf pages': number;
|
1969 | 'column-store internal pages': number;
|
1970 | 'column-store variable-size RLE encoded values': number;
|
1971 | 'column-store variable-size deleted values': number;
|
1972 | 'column-store variable-size leaf pages': number;
|
1973 | 'fixed-record size': number;
|
1974 | 'maximum internal page key size': number;
|
1975 | 'maximum internal page size': number;
|
1976 | 'maximum leaf page key size': number;
|
1977 | 'maximum leaf page size': number;
|
1978 | 'maximum leaf page value size': number;
|
1979 | 'maximum tree depth': number;
|
1980 | 'number of key/value pairs': number;
|
1981 | 'overflow pages': number;
|
1982 | 'pages rewritten by compaction': number;
|
1983 | 'row-store internal pages': number;
|
1984 | 'row-store leaf pages': number;
|
1985 | };
|
1986 | cache: {
|
1987 | 'bytes currently in the cache': number;
|
1988 | 'bytes read into cache': number;
|
1989 | 'bytes written from cache': number;
|
1990 | 'checkpoint blocked page eviction': number;
|
1991 | 'data source pages selected for eviction unable to be evicted': number;
|
1992 | 'hazard pointer blocked page eviction': number;
|
1993 | 'in-memory page passed criteria to be split': number;
|
1994 | 'in-memory page splits': number;
|
1995 | 'internal pages evicted': number;
|
1996 | 'internal pages split during eviction': number;
|
1997 | 'leaf pages split during eviction': number;
|
1998 | 'modified pages evicted': number;
|
1999 | 'overflow pages read into cache': number;
|
2000 | 'overflow values cached in memory': number;
|
2001 | 'page split during eviction deepened the tree': number;
|
2002 | 'page written requiring lookaside records': number;
|
2003 | 'pages read into cache': number;
|
2004 | 'pages read into cache requiring lookaside entries': number;
|
2005 | 'pages requested from the cache': number;
|
2006 | 'pages written from cache': number;
|
2007 | 'pages written requiring in-memory restoration': number;
|
2008 | 'tracked dirty bytes in the cache': number;
|
2009 | 'unmodified pages evicted': number;
|
2010 | };
|
2011 | cache_walk: {
|
2012 | 'Average difference between current eviction generation when the page was last considered': number;
|
2013 | 'Average on-disk page image size seen': number;
|
2014 | 'Clean pages currently in cache': number;
|
2015 | 'Current eviction generation': number;
|
2016 | 'Dirty pages currently in cache': number;
|
2017 | 'Entries in the root page': number;
|
2018 | 'Internal pages currently in cache': number;
|
2019 | 'Leaf pages currently in cache': number;
|
2020 | 'Maximum difference between current eviction generation when the page was last considered': number;
|
2021 | 'Maximum page size seen': number;
|
2022 | 'Minimum on-disk page image size seen': number;
|
2023 | 'On-disk page image sizes smaller than a single allocation unit': number;
|
2024 | 'Pages created in memory and never written': number;
|
2025 | 'Pages currently queued for eviction': number;
|
2026 | 'Pages that could not be queued for eviction': number;
|
2027 | 'Refs skipped during cache traversal': number;
|
2028 | 'Size of the root page': number;
|
2029 | 'Total number of pages currently in cache': number;
|
2030 | };
|
2031 | compression: {
|
2032 | 'compressed pages read': number;
|
2033 | 'compressed pages written': number;
|
2034 | 'page written failed to compress': number;
|
2035 | 'page written was too small to compress': number;
|
2036 | 'raw compression call failed, additional data available': number;
|
2037 | 'raw compression call failed, no additional data available': number;
|
2038 | 'raw compression call succeeded': number;
|
2039 | };
|
2040 | cursor: {
|
2041 | 'bulk-loaded cursor-insert calls': number;
|
2042 | 'create calls': number;
|
2043 | 'cursor-insert key and value bytes inserted': number;
|
2044 | 'cursor-remove key bytes removed': number;
|
2045 | 'cursor-update value bytes updated': number;
|
2046 | 'insert calls': number;
|
2047 | 'next calls': number;
|
2048 | 'prev calls': number;
|
2049 | 'remove calls': number;
|
2050 | 'reset calls': number;
|
2051 | 'restarted searches': number;
|
2052 | 'search calls': number;
|
2053 | 'search near calls': number;
|
2054 | 'truncate calls': number;
|
2055 | 'update calls': number;
|
2056 | };
|
2057 | reconciliation: {
|
2058 | 'dictionary matches': number;
|
2059 | 'fast-path pages deleted': number;
|
2060 | 'internal page key bytes discarded using suffix compression': number;
|
2061 | 'internal page multi-block writes': number;
|
2062 | 'internal-page overflow keys': number;
|
2063 | 'leaf page key bytes discarded using prefix compression': number;
|
2064 | 'leaf page multi-block writes': number;
|
2065 | 'leaf-page overflow keys': number;
|
2066 | 'maximum blocks required for a page': number;
|
2067 | 'overflow values written': number;
|
2068 | 'page checksum matches': number;
|
2069 | 'page reconciliation calls': number;
|
2070 | 'page reconciliation calls for eviction': number;
|
2071 | 'pages deleted': number;
|
2072 | };
|
2073 | }
|
2074 |
|
2075 |
|
2076 | export interface CollectionAggregationOptions {
|
2077 | readPreference?: ReadPreferenceOrMode;
|
2078 | |
2079 |
|
2080 |
|
2081 |
|
2082 | cursor?: { batchSize?: number };
|
2083 | |
2084 |
|
2085 |
|
2086 | explain?: boolean;
|
2087 | |
2088 |
|
2089 |
|
2090 |
|
2091 | allowDiskUse?: boolean;
|
2092 | |
2093 |
|
2094 |
|
2095 |
|
2096 | maxTimeMS?: number;
|
2097 | |
2098 |
|
2099 |
|
2100 | bypassDocumentValidation?: boolean;
|
2101 | hint?: string | object;
|
2102 | raw?: boolean;
|
2103 | promoteLongs?: boolean;
|
2104 | promoteValues?: boolean;
|
2105 | promoteBuffers?: boolean;
|
2106 | collation?: CollationDocument;
|
2107 | comment?: string;
|
2108 | session?: ClientSession;
|
2109 | }
|
2110 |
|
2111 |
|
2112 | export interface CollectionInsertManyOptions extends CommonOptions {
|
2113 | |
2114 |
|
2115 |
|
2116 | serializeFunctions?: boolean;
|
2117 | |
2118 |
|
2119 |
|
2120 | forceServerObjectId?: boolean;
|
2121 | |
2122 |
|
2123 |
|
2124 | bypassDocumentValidation?: boolean;
|
2125 | |
2126 |
|
2127 |
|
2128 | ordered?: boolean;
|
2129 | }
|
2130 |
|
2131 |
|
2132 | export interface CollectionBulkWriteOptions extends CommonOptions {
|
2133 | |
2134 |
|
2135 |
|
2136 | serializeFunctions?: boolean;
|
2137 | |
2138 |
|
2139 |
|
2140 | ordered?: boolean;
|
2141 | |
2142 |
|
2143 |
|
2144 | bypassDocumentValidation?: boolean;
|
2145 |
|
2146 | forceServerObjectId?: boolean;
|
2147 | }
|
2148 |
|
2149 |
|
2150 | export interface BulkWriteOpResultObject {
|
2151 | insertedCount?: number;
|
2152 | matchedCount?: number;
|
2153 | modifiedCount?: number;
|
2154 | deletedCount?: number;
|
2155 | upsertedCount?: number;
|
2156 | insertedIds?: {[index: number]: any};
|
2157 | upsertedIds?: {[index: number]: any};
|
2158 | result?: any;
|
2159 | }
|
2160 |
|
2161 |
|
2162 | export interface MongoCountPreferences {
|
2163 | |
2164 |
|
2165 |
|
2166 | limit?: number;
|
2167 | |
2168 |
|
2169 |
|
2170 | skip?: number;
|
2171 | |
2172 |
|
2173 |
|
2174 | hint?: string;
|
2175 | |
2176 |
|
2177 |
|
2178 | readPreference?: ReadPreferenceOrMode;
|
2179 | |
2180 |
|
2181 |
|
2182 | maxTimeMS?: number;
|
2183 | |
2184 |
|
2185 |
|
2186 | session?: ClientSession;
|
2187 | }
|
2188 |
|
2189 |
|
2190 | export interface MongoDistinctPreferences {
|
2191 | |
2192 |
|
2193 |
|
2194 | readPreference?: ReadPreferenceOrMode;
|
2195 | |
2196 |
|
2197 |
|
2198 | maxTimeMS?: number;
|
2199 | |
2200 |
|
2201 |
|
2202 | session?: ClientSession;
|
2203 | }
|
2204 |
|
2205 |
|
2206 | export interface DeleteWriteOpResultObject {
|
2207 |
|
2208 | result: {
|
2209 |
|
2210 | ok?: number;
|
2211 |
|
2212 | n?: number;
|
2213 | };
|
2214 |
|
2215 | connection?: any;
|
2216 |
|
2217 | deletedCount?: number;
|
2218 | }
|
2219 |
|
2220 |
|
2221 | export interface FindAndModifyWriteOpResultObject<TSchema> {
|
2222 |
|
2223 | value?: TSchema;
|
2224 |
|
2225 | lastErrorObject?: any;
|
2226 |
|
2227 | ok?: number;
|
2228 | }
|
2229 |
|
2230 |
|
2231 | export interface FindOneAndReplaceOption<T> extends CommonOptions {
|
2232 | projection?: SchemaMember<T, ProjectionOperators | number | boolean | any>;
|
2233 | sort?: SortOptionObject<T>;
|
2234 | maxTimeMS?: number;
|
2235 | upsert?: boolean;
|
2236 | returnOriginal?: boolean;
|
2237 | collation?: CollationDocument;
|
2238 | }
|
2239 |
|
2240 |
|
2241 | export interface ProjectionOperators {
|
2242 |
|
2243 | $elemMatch?: object;
|
2244 |
|
2245 | $slice?: number | [number, number];
|
2246 | $meta?: MetaProjectionOperators;
|
2247 | }
|
2248 |
|
2249 |
|
2250 | export interface FindOneAndUpdateOption<T> extends FindOneAndReplaceOption<T> {
|
2251 | arrayFilters?: object[];
|
2252 | }
|
2253 |
|
2254 |
|
2255 | export interface FindOneAndDeleteOption<T> {
|
2256 | projection?: SchemaMember<T, ProjectionOperators | number | boolean | any>;
|
2257 | sort?: SortOptionObject<T>;
|
2258 | maxTimeMS?: number;
|
2259 | session?: ClientSession;
|
2260 | collation?: CollationDocument;
|
2261 | }
|
2262 |
|
2263 |
|
2264 | export interface GeoHaystackSearchOptions {
|
2265 | readPreference?: ReadPreferenceOrMode;
|
2266 | maxDistance?: number;
|
2267 | search?: object;
|
2268 | limit?: number;
|
2269 | session?: ClientSession;
|
2270 | }
|
2271 |
|
2272 |
|
2273 | export class Code {
|
2274 | constructor(code: string | Function, scope?: object);
|
2275 | code: string | Function;
|
2276 | scope: any;
|
2277 | }
|
2278 |
|
2279 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/OrderedBulkOperation.html */
|
2280 | export interface OrderedBulkOperation {
|
2281 | length: number;
|
2282 |
|
2283 | execute(callback: MongoCallback<BulkWriteResult>): void;
|
2284 | execute(options?: FSyncOptions): Promise<BulkWriteResult>;
|
2285 | execute(options: FSyncOptions, callback: MongoCallback<BulkWriteResult>): void;
|
2286 |
|
2287 | find(selector: object): FindOperatorsOrdered;
|
2288 |
|
2289 | insert(doc: object): OrderedBulkOperation;
|
2290 | }
|
2291 |
|
2292 |
|
2293 | export interface BulkWriteResultUpsertedIdObject {
|
2294 | index: number;
|
2295 | _id: ObjectId;
|
2296 | }
|
2297 |
|
2298 |
|
2299 | export interface BulkWriteResult {
|
2300 | |
2301 |
|
2302 |
|
2303 | ok: boolean;
|
2304 |
|
2305 | |
2306 |
|
2307 |
|
2308 |
|
2309 |
|
2310 | nInserted: number;
|
2311 |
|
2312 | |
2313 |
|
2314 |
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 | nMatched: number;
|
2320 |
|
2321 | |
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 | nModified: number;
|
2329 |
|
2330 | |
2331 |
|
2332 |
|
2333 |
|
2334 | nUpserted: number;
|
2335 |
|
2336 | |
2337 |
|
2338 |
|
2339 | nRemoved: number;
|
2340 |
|
2341 |
|
2342 | getInsertedIds(): object[];
|
2343 |
|
2344 | getLastOp(): object;
|
2345 |
|
2346 | getRawResponse(): object;
|
2347 |
|
2348 | |
2349 |
|
2350 |
|
2351 |
|
2352 | getUpsertedIdAt(index: number): BulkWriteResultUpsertedIdObject;
|
2353 |
|
2354 |
|
2355 | getUpsertedIds(): BulkWriteResultUpsertedIdObject[];
|
2356 |
|
2357 | getWriteConcernError(): WriteConcernError;
|
2358 |
|
2359 | |
2360 |
|
2361 |
|
2362 |
|
2363 | getWriteErrorAt(index: number): WriteError;
|
2364 |
|
2365 |
|
2366 | getWriteErrorCount(): number;
|
2367 |
|
2368 | getWriteErrors(): object[];
|
2369 |
|
2370 | hasWriteErrors(): boolean;
|
2371 | }
|
2372 |
|
2373 |
|
2374 | export interface WriteError {
|
2375 |
|
2376 | code: number;
|
2377 |
|
2378 | index: number;
|
2379 |
|
2380 | errmsg: string;
|
2381 | }
|
2382 |
|
2383 |
|
2384 | export interface WriteConcernError {
|
2385 |
|
2386 | code: number;
|
2387 |
|
2388 | errmsg: string;
|
2389 | }
|
2390 |
|
2391 |
|
2392 | export interface FindOperatorsOrdered {
|
2393 | delete(): OrderedBulkOperation;
|
2394 | deleteOne(): OrderedBulkOperation;
|
2395 | replaceOne(doc: object): OrderedBulkOperation;
|
2396 | update(doc: object): OrderedBulkOperation;
|
2397 | updateOne(doc: object): OrderedBulkOperation;
|
2398 | upsert(): FindOperatorsOrdered;
|
2399 | }
|
2400 |
|
2401 |
|
2402 | export interface UnorderedBulkOperation {
|
2403 |
|
2404 | length: number;
|
2405 |
|
2406 | execute(callback: MongoCallback<BulkWriteResult>): void;
|
2407 | execute(options?: FSyncOptions): Promise<BulkWriteResult>;
|
2408 | execute(options: FSyncOptions, callback: MongoCallback<BulkWriteResult>): void;
|
2409 |
|
2410 | find(selector: object): FindOperatorsUnordered;
|
2411 |
|
2412 | insert(doc: object): UnorderedBulkOperation;
|
2413 | }
|
2414 |
|
2415 |
|
2416 | export interface FindOperatorsUnordered {
|
2417 | length: number;
|
2418 | remove(): UnorderedBulkOperation;
|
2419 | removeOne(): UnorderedBulkOperation;
|
2420 | replaceOne(doc: object): UnorderedBulkOperation;
|
2421 | update(doc: object): UnorderedBulkOperation;
|
2422 | updateOne(doc: object): UnorderedBulkOperation;
|
2423 | upsert(): FindOperatorsUnordered;
|
2424 | }
|
2425 |
|
2426 |
|
2427 | export interface FindOneOptions<T> {
|
2428 | limit?: number;
|
2429 | sort?: Array<[string, number]> | SortOptionObject<T>;
|
2430 | projection?: SchemaMember<T, ProjectionOperators | number | boolean | any>;
|
2431 | |
2432 |
|
2433 |
|
2434 | fields?: { [P in keyof T]: boolean | number };
|
2435 | skip?: number;
|
2436 | hint?: object;
|
2437 | explain?: boolean;
|
2438 | snapshot?: boolean;
|
2439 | timeout?: boolean;
|
2440 | tailable?: boolean;
|
2441 | awaitData?: boolean;
|
2442 | batchSize?: number;
|
2443 | returnKey?: boolean;
|
2444 | maxScan?: number;
|
2445 | min?: number;
|
2446 | max?: number;
|
2447 | showDiskLoc?: boolean;
|
2448 | comment?: string;
|
2449 | raw?: boolean;
|
2450 | promoteLongs?: boolean;
|
2451 | promoteValues?: boolean;
|
2452 | promoteBuffers?: boolean;
|
2453 | readPreference?: ReadPreferenceOrMode;
|
2454 | partial?: boolean;
|
2455 | maxTimeMS?: number;
|
2456 | collation?: CollationDocument;
|
2457 | session?: ClientSession;
|
2458 | }
|
2459 |
|
2460 |
|
2461 | export interface CollectionInsertOneOptions extends CommonOptions {
|
2462 | |
2463 |
|
2464 |
|
2465 | serializeFunctions?: boolean;
|
2466 |
|
2467 | forceServerObjectId?: boolean;
|
2468 |
|
2469 | bypassDocumentValidation?: boolean;
|
2470 | }
|
2471 |
|
2472 |
|
2473 | export interface InsertWriteOpResult<TSchema extends { _id: any }> {
|
2474 | insertedCount: number;
|
2475 | ops: TSchema[];
|
2476 | insertedIds: { [key: number]: TSchema['_id'] };
|
2477 | connection: any;
|
2478 | result: { ok: number; n: number };
|
2479 | }
|
2480 |
|
2481 |
|
2482 | export interface InsertOneWriteOpResult<TSchema extends { _id: any }> {
|
2483 | insertedCount: number;
|
2484 | ops: TSchema[];
|
2485 | insertedId: TSchema['_id'];
|
2486 | connection: any;
|
2487 | result: { ok: number; n: number };
|
2488 | }
|
2489 |
|
2490 |
|
2491 | export interface ParallelCollectionScanOptions {
|
2492 | readPreference?: ReadPreferenceOrMode;
|
2493 | batchSize?: number;
|
2494 | numCursors?: number;
|
2495 | raw?: boolean;
|
2496 | session?: ClientSession;
|
2497 | }
|
2498 |
|
2499 |
|
2500 | export interface ReplaceOneOptions extends CommonOptions {
|
2501 | upsert?: boolean;
|
2502 | bypassDocumentValidation?: boolean;
|
2503 | }
|
2504 |
|
2505 |
|
2506 | export interface UpdateOneOptions extends ReplaceOneOptions {
|
2507 | arrayFilters?: object[];
|
2508 | }
|
2509 |
|
2510 |
|
2511 | export interface UpdateManyOptions extends CommonOptions {
|
2512 | upsert?: boolean;
|
2513 | arrayFilters?: object[];
|
2514 | }
|
2515 |
|
2516 |
|
2517 | export interface UpdateWriteOpResult {
|
2518 | result: { ok: number; n: number; nModified: number };
|
2519 | connection: any;
|
2520 | matchedCount: number;
|
2521 | modifiedCount: number;
|
2522 | upsertedCount: number;
|
2523 | upsertedId: { _id: ObjectId };
|
2524 | }
|
2525 |
|
2526 |
|
2527 | export interface ReplaceWriteOpResult extends UpdateWriteOpResult {
|
2528 | ops: any[];
|
2529 | }
|
2530 |
|
2531 |
|
2532 | export interface MapReduceOptions {
|
2533 | readPreference?: ReadPreferenceOrMode;
|
2534 | out?: object;
|
2535 | query?: object;
|
2536 | sort?: object;
|
2537 | limit?: number;
|
2538 | keeptemp?: boolean;
|
2539 | finalize?: Function | string;
|
2540 | scope?: object;
|
2541 | jsMode?: boolean;
|
2542 | verbose?: boolean;
|
2543 | bypassDocumentValidation?: boolean;
|
2544 | session?: ClientSession;
|
2545 | }
|
2546 |
|
2547 | export type CollectionMapFunction<TSchema> = (this: TSchema) => void;
|
2548 |
|
2549 | export type CollectionReduceFunction<TKey, TValue> = (key: TKey, values: TValue[]) => TValue;
|
2550 |
|
2551 |
|
2552 | export interface WriteOpResult {
|
2553 | ops: any[];
|
2554 | connection: any;
|
2555 | result: any;
|
2556 | }
|
2557 |
|
2558 |
|
2559 | export type CursorResult = object | null | boolean;
|
2560 |
|
2561 | type Default = any;
|
2562 | type DefaultSchema = any;
|
2563 |
|
2564 |
|
2565 | export class Cursor<T = Default> extends Readable {
|
2566 | [Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
2567 | sortValue: string;
|
2568 | timeout: boolean;
|
2569 | readPreference: ReadPreference;
|
2570 |
|
2571 | addCursorFlag(flag: string, value: boolean): Cursor<T>;
|
2572 |
|
2573 | addQueryModifier(name: string, value: boolean): Cursor<T>;
|
2574 |
|
2575 | batchSize(value: number): Cursor<T>;
|
2576 | bufferedCount(): number;
|
2577 |
|
2578 | clone(): Cursor<T>;
|
2579 |
|
2580 | close(): Promise<CursorResult>;
|
2581 | close(callback: MongoCallback<CursorResult>): void;
|
2582 |
|
2583 | collation(value: CollationDocument): Cursor<T>;
|
2584 |
|
2585 | comment(value: string): Cursor<T>;
|
2586 |
|
2587 | count(callback: MongoCallback<number>): void;
|
2588 | count(applySkipLimit: boolean, callback: MongoCallback<number>): void;
|
2589 | count(options: CursorCommentOptions, callback: MongoCallback<number>): void;
|
2590 | count(applySkipLimit: boolean, options: CursorCommentOptions, callback: MongoCallback<number>): void;
|
2591 | count(applySkipLimit?: boolean, options?: CursorCommentOptions): Promise<number>;
|
2592 |
|
2593 | explain(): Promise<CursorResult>;
|
2594 | explain(callback: MongoCallback<CursorResult>): void;
|
2595 |
|
2596 | filter(filter: object): Cursor<T>;
|
2597 |
|
2598 | forEach(iterator: IteratorCallback<T>, callback: EndCallback): void;
|
2599 | forEach(iterator: IteratorCallback<T>): Promise<void>;
|
2600 |
|
2601 | hasNext(): Promise<boolean>;
|
2602 | hasNext(callback: MongoCallback<boolean>): void;
|
2603 |
|
2604 | hint(hint: string | object): Cursor<T>;
|
2605 |
|
2606 | isClosed(): boolean;
|
2607 |
|
2608 | limit(value: number): Cursor<T>;
|
2609 |
|
2610 | map<U>(transform: (document: T) => U): Cursor<U>;
|
2611 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#max */
|
2612 | max(max: object): Cursor<T>;
|
2613 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxAwaitTimeMS */
|
2614 | maxAwaitTimeMS(value: number): Cursor<T>;
|
2615 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxScan */
|
2616 | maxScan(maxScan: object): Cursor<T>;
|
2617 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#maxTimeMS */
|
2618 | maxTimeMS(value: number): Cursor<T>;
|
2619 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#min */
|
2620 | min(min: object): Cursor<T>;
|
2621 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#next */
|
2622 | next(): Promise<T | null>;
|
2623 | next(callback: MongoCallback<T | null>): void;
|
2624 | /** http://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#project */
|
2625 | project(value: SchemaMember<T, ProjectionOperators | number | boolean | any>): Cursor<T>;
|
2626 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#read */
|
2627 | read(size: number): string | Buffer | void;
|
2628 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#returnKey */
|
2629 | returnKey(returnKey: boolean): Cursor<T>;
|
2630 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#rewind */
|
2631 | rewind(): void;
|
2632 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#setCursorOption */
|
2633 | setCursorOption(field: string, value: object): Cursor<T>;
|
2634 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#setReadPreference */
|
2635 | setReadPreference(readPreference: ReadPreferenceOrMode): Cursor<T>;
|
2636 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#showRecordId */
|
2637 | showRecordId(showRecordId: boolean): Cursor<T>;
|
2638 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#skip */
|
2639 | skip(value: number): Cursor<T>;
|
2640 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#snapshot */
|
2641 | snapshot(snapshot: object): Cursor<T>;
|
2642 | /** http://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#sort */
|
2643 | sort(keyOrList: string | Array<[string, number]> | SortOptionObject<T>, direction?: number): Cursor<T>;
|
2644 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#stream */
|
2645 | stream(options?: { transform?: (document: T) => any }): Cursor<T>;
|
2646 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#toArray */
|
2647 | toArray(): Promise<T[]>;
|
2648 | toArray(callback: MongoCallback<T[]>): void;
|
2649 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#unshift */
|
2650 | unshift(stream: Buffer | string): void;
|
2651 | }
|
2652 |
|
2653 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#count */
|
2654 | export interface CursorCommentOptions {
|
2655 | skip?: number;
|
2656 | limit?: number;
|
2657 | maxTimeMS?: number;
|
2658 | hint?: string;
|
2659 | readPreference?: ReadPreferenceOrMode;
|
2660 | }
|
2661 |
|
2662 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#~iteratorCallback */
|
2663 | export interface IteratorCallback<T> {
|
2664 | (doc: T): void;
|
2665 | }
|
2666 |
|
2667 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/Cursor.html#~endCallback */
|
2668 | export interface EndCallback {
|
2669 | (error: MongoError): void;
|
2670 | }
|
2671 |
|
2672 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#~resultCallback */
|
2673 | export type AggregationCursorResult = object | null;
|
2674 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html */
|
2675 | export class AggregationCursor<T = Default> extends Cursor<T> {
|
2676 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#batchSize */
|
2677 | batchSize(value: number): AggregationCursor<T>;
|
2678 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#clone */
|
2679 | clone(): AggregationCursor<T>;
|
2680 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#close */
|
2681 | close(): Promise<AggregationCursorResult>;
|
2682 | close(callback: MongoCallback<AggregationCursorResult>): void;
|
2683 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#each */
|
2684 | each(callback: MongoCallback<AggregationCursorResult>): void;
|
2685 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#explain */
|
2686 | explain(): Promise<AggregationCursorResult>;
|
2687 | explain(callback: MongoCallback<AggregationCursorResult>): void;
|
2688 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#geoNear */
|
2689 | geoNear(document: object): AggregationCursor<T>;
|
2690 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#group */
|
2691 | group<U = T>(document: object): AggregationCursor<U>;
|
2692 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#hasNext */
|
2693 | hasNext(): Promise<boolean>;
|
2694 | hasNext(callback: MongoCallback<boolean>): void;
|
2695 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#isClosed */
|
2696 | isClosed(): boolean;
|
2697 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#limit */
|
2698 | limit(value: number): AggregationCursor<T>;
|
2699 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#lookup */
|
2700 | lookup(document: object): AggregationCursor<T>;
|
2701 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#match */
|
2702 | match(document: object): AggregationCursor<T>;
|
2703 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#maxTimeMS */
|
2704 | maxTimeMS(value: number): AggregationCursor<T>;
|
2705 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#next */
|
2706 | next(): Promise<T | null>;
|
2707 | next(callback: MongoCallback<T | null>): void;
|
2708 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#out */
|
2709 | out(destination: string): AggregationCursor<T>;
|
2710 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#project */
|
2711 | project<U = T>(document: object): AggregationCursor<U>;
|
2712 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#read */
|
2713 | read(size: number): string | Buffer | void;
|
2714 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#redact */
|
2715 | redact(document: object): AggregationCursor<T>;
|
2716 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#rewind */
|
2717 | rewind(): AggregationCursor<T>;
|
2718 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#setEncoding */
|
2719 | skip(value: number): AggregationCursor<T>;
|
2720 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#sort */
|
2721 | sort(document: object): AggregationCursor<T>;
|
2722 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#toArray */
|
2723 | toArray(): Promise<T[]>;
|
2724 | toArray(callback: MongoCallback<T[]>): void;
|
2725 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#unshift */
|
2726 | unshift(stream: Buffer | string): void;
|
2727 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/AggregationCursor.html#unwind */
|
2728 | unwind<U = T>(field: string | { path: string; includeArrayIndex?: string; preserveNullAndEmptyArrays?: boolean; }): AggregationCursor<U>;
|
2729 | }
|
2730 |
|
2731 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#~resultCallback */
|
2732 | export type CommandCursorResult = object | null;
|
2733 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html */
|
2734 | export class CommandCursor extends Readable {
|
2735 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#hasNext */
|
2736 | hasNext(): Promise<boolean>;
|
2737 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#hasNext */
|
2738 | hasNext(callback: MongoCallback<boolean>): void;
|
2739 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#batchSize */
|
2740 | batchSize(value: number): CommandCursor;
|
2741 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#clone */
|
2742 | clone(): CommandCursor;
|
2743 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#close */
|
2744 | close(): Promise<CommandCursorResult>;
|
2745 | close(callback: MongoCallback<CommandCursorResult>): void;
|
2746 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#each */
|
2747 | each(callback: MongoCallback<CommandCursorResult>): void;
|
2748 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#isClosed */
|
2749 | isClosed(): boolean;
|
2750 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#maxTimeMS */
|
2751 | maxTimeMS(value: number): CommandCursor;
|
2752 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#next */
|
2753 | next(): Promise<CommandCursorResult>;
|
2754 | next(callback: MongoCallback<CommandCursorResult>): void;
|
2755 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#read */
|
2756 | read(size: number): string | Buffer | void;
|
2757 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#rewind */
|
2758 | rewind(): CommandCursor;
|
2759 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#setReadPreference */
|
2760 | setReadPreference(readPreference: ReadPreferenceOrMode): CommandCursor;
|
2761 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#toArray */
|
2762 | toArray(): Promise<any[]>;
|
2763 | toArray(callback: MongoCallback<any[]>): void;
|
2764 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/CommandCursor.html#unshift */
|
2765 | unshift(stream: Buffer | string): void;
|
2766 | }
|
2767 |
|
2768 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html */
|
2769 | export class GridFSBucket {
|
2770 | constructor(db: Db, options?: GridFSBucketOptions);
|
2771 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#delete */
|
2772 | delete(id: ObjectId, callback?: GridFSBucketErrorCallback): void;
|
2773 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#drop */
|
2774 | drop(callback?: GridFSBucketErrorCallback): void;
|
2775 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#find */
|
2776 | find(filter?: object, options?: GridFSBucketFindOptions): Cursor<any>;
|
2777 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openDownloadStream */
|
2778 | openDownloadStream(id: ObjectId, options?: { start: number; end: number }): GridFSBucketReadStream;
|
2779 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openDownloadStreamByName */
|
2780 | openDownloadStreamByName(
|
2781 | filename: string,
|
2782 | options?: { revision: number; start: number; end: number },
|
2783 | ): GridFSBucketReadStream;
|
2784 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openUploadStream */
|
2785 | openUploadStream(filename: string, options?: GridFSBucketOpenUploadStreamOptions): GridFSBucketWriteStream;
|
2786 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openUploadStreamWithId */
|
2787 | openUploadStreamWithId(
|
2788 | id: GridFSBucketWriteStreamId,
|
2789 | filename: string,
|
2790 | options?: GridFSBucketOpenUploadStreamOptions,
|
2791 | ): GridFSBucketWriteStream;
|
2792 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#rename */
|
2793 | rename(id: ObjectId, filename: string, callback?: GridFSBucketErrorCallback): void;
|
2794 | }
|
2795 |
|
2796 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html */
|
2797 | export interface GridFSBucketOptions {
|
2798 | bucketName?: string;
|
2799 | chunkSizeBytes?: number;
|
2800 | writeConcern?: WriteConcern;
|
2801 | readPreference?: ReadPreferenceOrMode;
|
2802 | }
|
2803 |
|
2804 | /** http://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucket.html#~errorCallback */
|
2805 | export interface GridFSBucketErrorCallback extends MongoCallback<void> {}
|
2806 |
|
2807 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#find */
|
2808 | export interface GridFSBucketFindOptions {
|
2809 | batchSize?: number;
|
2810 | limit?: number;
|
2811 | maxTimeMS?: number;
|
2812 | noCursorTimeout?: boolean;
|
2813 | skip?: number;
|
2814 | sort?: object;
|
2815 | }
|
2816 |
|
2817 | /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucket.html#openUploadStream */
|
2818 | export interface GridFSBucketOpenUploadStreamOptions {
|
2819 | chunkSizeBytes?: number;
|
2820 | metadata?: object;
|
2821 | contentType?: string;
|
2822 | aliases?: string[];
|
2823 | }
|
2824 |
|
2825 | /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketReadStream.html */
|
2826 | export class GridFSBucketReadStream extends Readable {
|
2827 | id: ObjectId;
|
2828 | constructor(
|
2829 | chunks: Collection<any>,
|
2830 | files: Collection<any>,
|
2831 | readPreference: object,
|
2832 | filter: object,
|
2833 | options?: GridFSBucketReadStreamOptions,
|
2834 | );
|
2835 | }
|
2836 |
|
2837 | /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketReadStream.html */
|
2838 | export interface GridFSBucketReadStreamOptions {
|
2839 | sort?: number;
|
2840 | skip?: number;
|
2841 | start?: number;
|
2842 | end?: number;
|
2843 | }
|
2844 |
|
2845 | /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketWriteStream.html */
|
2846 | export class GridFSBucketWriteStream extends Writable {
|
2847 | id: GridFSBucketWriteStreamId;
|
2848 | constructor(bucket: GridFSBucket, filename: string, options?: GridFSBucketWriteStreamOptions);
|
2849 |
|
2850 | /**
|
2851 | * Places this write stream into an aborted state (all future writes fail)
|
2852 | * and deletes all chunks that have already been written.
|
2853 | * @param [callback] called when chunks are successfully removed or error occurred
|
2854 | * @see {@link https://mongodb.github.io/node-mongodb-native/3.6/api/GridFSBucketWriteStream.html#abort}
|
2855 | */
|
2856 | abort(callback?: GridFSBucketErrorCallback): void;
|
2857 | }
|
2858 |
|
2859 | /** https://mongodb.github.io/node-mongodb-native/3.1/api/GridFSBucketWriteStream.html */
|
2860 | export interface GridFSBucketWriteStreamOptions extends WriteConcern {
|
2861 | /**
|
2862 | * Custom file id for the GridFS file.
|
2863 | */
|
2864 | id?: GridFSBucketWriteStreamId;
|
2865 | /**
|
2866 | * The chunk size to use, in bytes
|
2867 | */
|
2868 | chunkSizeBytes?: number;
|
2869 | /**
|
2870 | * Default false; If true, disables adding an md5 field to file data
|
2871 | */
|
2872 | disableMD5?: boolean;
|
2873 | }
|
2874 |
|
2875 | /**
|
2876 | * This is similar to Parameters but will work with a type which is
|
2877 | * a function or with a tuple specifying arguments, which are both
|
2878 | * common ways to define eventemitter events
|
2879 | */
|
2880 | type EventArguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [undefined] ? [] : [T];
|
2881 |
|
2882 |
|
2883 |
|
2884 |
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 | declare class TypedEventEmitter<Events> {
|
2901 | addListener<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2902 | on<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2903 | once<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2904 | prependListener<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2905 | prependOnceListener<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2906 |
|
2907 | off<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2908 | removeAllListeners<E extends keyof Events>(event?: E): this;
|
2909 | removeListener<E extends keyof Events>(event: E, listener: Events[E]): this;
|
2910 |
|
2911 | emit<E extends keyof Events>(event: E, ...args: EventArguments<Events[E]>): boolean;
|
2912 | eventNames(): Array<keyof Events>;
|
2913 | rawListeners<E extends keyof Events>(event: E): Function[];
|
2914 | listeners<E extends keyof Events>(event: E): Function[];
|
2915 | listenerCount<E extends keyof Events>(event: E): number;
|
2916 |
|
2917 | getMaxListeners(): number;
|
2918 | setMaxListeners(maxListeners: number): this;
|
2919 | }
|
2920 |
|
2921 | interface ChangeStreamEvents<TSchema extends { [key: string]: any } = DefaultSchema> {
|
2922 | change: (doc: ChangeEvent<TSchema>) => void;
|
2923 | close: () => void;
|
2924 | end: () => void;
|
2925 | error: (err: MongoError) => void;
|
2926 | resumeTokenChanged: (newToken: ResumeToken) => void;
|
2927 | }
|
2928 |
|
2929 |
|
2930 | export class ChangeStream<TSchema extends { [key: string]: any } = DefaultSchema> extends TypedEventEmitter<
|
2931 | ChangeStreamEvents<TSchema>
|
2932 | > {
|
2933 | resumeToken: ResumeToken;
|
2934 |
|
2935 | constructor(parent: MongoClient | Db | Collection, pipeline: object[], options?: ChangeStreamOptions);
|
2936 |
|
2937 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#close */
|
2938 | close(): Promise<any>;
|
2939 | close(callback: MongoCallback<any>): void;
|
2940 |
|
2941 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#hasNext */
|
2942 | hasNext(): Promise<any>;
|
2943 | hasNext(callback: MongoCallback<any>): void;
|
2944 |
|
2945 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#isClosed */
|
2946 | isClosed(): boolean;
|
2947 |
|
2948 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#next */
|
2949 | next(): Promise<any>;
|
2950 | next(callback: MongoCallback<any>): void;
|
2951 |
|
2952 | /** http://mongodb.github.io/node-mongodb-native/3.1/api/ChangeStream.html#stream */
|
2953 | stream(options?: { transform?: Function }): Cursor;
|
2954 | }
|
2955 |
|
2956 | export class ResumeToken {}
|
2957 |
|
2958 | export type ChangeEventTypes =
|
2959 | | 'insert'
|
2960 | | 'delete'
|
2961 | | 'replace'
|
2962 | | 'update'
|
2963 | | 'drop'
|
2964 | | 'rename'
|
2965 | | 'dropDatabase'
|
2966 | | 'invalidate';
|
2967 | export interface ChangeEventBase<TSchema extends { [key: string]: any } = DefaultSchema> {
|
2968 | _id: ResumeToken;
|
2969 | |
2970 |
|
2971 |
|
2972 |
|
2973 |
|
2974 | ns: {
|
2975 | db: string;
|
2976 | coll: string;
|
2977 | };
|
2978 | clusterTime: Timestamp;
|
2979 | txnNumber?: number;
|
2980 | lsid?: {
|
2981 | id: any;
|
2982 | uid: any;
|
2983 | };
|
2984 | }
|
2985 | export interface ChangeEventCR<TSchema extends { [key: string]: any } = DefaultSchema>
|
2986 | extends ChangeEventBase<TSchema> {
|
2987 | operationType: 'insert' | 'replace';
|
2988 | fullDocument?: TSchema;
|
2989 | documentKey: {
|
2990 | _id: ExtractIdType<TSchema>;
|
2991 | };
|
2992 | }
|
2993 | type FieldUpdates<TSchema> = Partial<TSchema> & { [key: string]: any };
|
2994 | export interface ChangeEventUpdate<TSchema extends { [key: string]: any } = DefaultSchema>
|
2995 | extends ChangeEventBase<TSchema> {
|
2996 | operationType: 'update';
|
2997 | updateDescription: {
|
2998 | |
2999 |
|
3000 |
|
3001 |
|
3002 | updatedFields: FieldUpdates<TSchema>;
|
3003 | removedFields: Array<keyof TSchema | string>;
|
3004 | };
|
3005 | fullDocument?: TSchema;
|
3006 | documentKey: {
|
3007 | _id: ExtractIdType<TSchema>;
|
3008 | };
|
3009 | }
|
3010 | export interface ChangeEventDelete<TSchema extends { [key: string]: any } = DefaultSchema>
|
3011 | extends ChangeEventBase<TSchema> {
|
3012 | operationType: 'delete';
|
3013 | documentKey: {
|
3014 | _id: ExtractIdType<TSchema>;
|
3015 | };
|
3016 | }
|
3017 | export interface ChangeEventRename<TSchema extends { [key: string]: any } = DefaultSchema>
|
3018 | extends ChangeEventBase<TSchema> {
|
3019 | operationType: 'rename';
|
3020 | to: {
|
3021 | db: string;
|
3022 | coll: string;
|
3023 | };
|
3024 | }
|
3025 |
|
3026 | export interface ChangeEventOther<TSchema extends { [key: string]: any } = DefaultSchema>
|
3027 | extends ChangeEventBase<TSchema> {
|
3028 | operationType: 'drop' | 'dropDatabase';
|
3029 | }
|
3030 |
|
3031 | export interface ChangeEventInvalidate<TSchema extends { [key: string]: any } = DefaultSchema> {
|
3032 | _id: ResumeToken;
|
3033 | operationType: 'invalidate';
|
3034 | clusterTime: Timestamp;
|
3035 | }
|
3036 |
|
3037 | export type ChangeEvent<TSchema extends object = { _id: ObjectId }> =
|
3038 | | ChangeEventCR<TSchema>
|
3039 | | ChangeEventUpdate<TSchema>
|
3040 | | ChangeEventDelete<TSchema>
|
3041 | | ChangeEventRename<TSchema>
|
3042 | | ChangeEventOther<TSchema>
|
3043 | | ChangeEventInvalidate<TSchema>;
|
3044 |
|
3045 |
|
3046 | export interface ChangeStreamOptions {
|
3047 | fullDocument?: 'default' | 'updateLookup';
|
3048 | maxAwaitTimeMS?: number;
|
3049 | resumeAfter?: ResumeToken;
|
3050 | startAfter?: ResumeToken;
|
3051 | startAtOperationTime?: Timestamp;
|
3052 | batchSize?: number;
|
3053 | collation?: CollationDocument;
|
3054 | readPreference?: ReadPreferenceOrMode;
|
3055 | }
|
3056 |
|
3057 | type GridFSBucketWriteStreamId = string | number | object | ObjectId;
|
3058 |
|
3059 | export interface LoggerOptions {
|
3060 | |
3061 |
|
3062 |
|
3063 | loggerLevel?: string;
|
3064 | |
3065 |
|
3066 |
|
3067 | logger?: log;
|
3068 | }
|
3069 |
|
3070 | export type log = (message?: string, state?: LoggerState) => void;
|
3071 |
|
3072 | export interface LoggerState {
|
3073 | type: string;
|
3074 | message: string;
|
3075 | className: string;
|
3076 | pid: number;
|
3077 | date: number;
|
3078 | }
|
3079 |
|
3080 |
|
3081 | export class Logger {
|
3082 | constructor(className: string, options?: LoggerOptions);
|
3083 | /**
|
3084 | * Log a message at the debug level
|
3085 | */
|
3086 | debug(message: string, state: LoggerState): void;
|
3087 | /**
|
3088 | * Log a message at the warn level
|
3089 | */
|
3090 | warn(message: string, state: LoggerState): void;
|
3091 | /**
|
3092 | * Log a message at the info level
|
3093 | */
|
3094 | info(message: string, state: LoggerState): void;
|
3095 | /**
|
3096 | * Log a message at the error level
|
3097 | */
|
3098 | error(message: string, state: LoggerState): void;
|
3099 | /**
|
3100 | * Is the logger set at info level
|
3101 | */
|
3102 | isInfo(): boolean;
|
3103 | /**
|
3104 | * Is the logger set at error level
|
3105 | */
|
3106 | isError(): boolean;
|
3107 | /**
|
3108 | * Is the logger set at error level
|
3109 | */
|
3110 | isWarn(): boolean;
|
3111 | /**
|
3112 | * Is the logger set at debug level
|
3113 | */
|
3114 | isDebug(): boolean;
|
3115 | /**
|
3116 | * Resets the logger to default settings, error and no filtered classes
|
3117 | */
|
3118 | static reset(): void;
|
3119 | /**
|
3120 | * Get the current logger function
|
3121 | */
|
3122 | static currentLogger(): log;
|
3123 | //Set the current logger function
|
3124 | static setCurrentLogger(log: log): void;
|
3125 | /**
|
3126 | * Set what classes to log.
|
3127 | */
|
3128 | static filter(type: string, values: string[]): void;
|
3129 | /**
|
3130 | * Set the current log level
|
3131 | */
|
3132 | static setLevel(level: string): void;
|
3133 | }
|
3134 |
|
3135 | /** https://docs.mongodb.com/manual/reference/collation/#collation-document-fields */
|
3136 | export interface CollationDocument {
|
3137 | locale: string;
|
3138 | strength?: number;
|
3139 | caseLevel?: boolean;
|
3140 | caseFirst?: string;
|
3141 | numericOrdering?: boolean;
|
3142 | alternate?: string;
|
3143 | maxVariable?: string;
|
3144 | backwards?: boolean;
|
3145 | normalization?: boolean;
|
3146 | }
|
3147 |
|
3148 |
|
3149 | export interface IndexSpecification {
|
3150 | key: object;
|
3151 | name?: string;
|
3152 | background?: boolean;
|
3153 | unique?: boolean;
|
3154 | partialFilterExpression?: object;
|
3155 | sparse?: boolean;
|
3156 | expireAfterSeconds?: number;
|
3157 | storageEngine?: object;
|
3158 | weights?: object;
|
3159 | default_language?: string;
|
3160 | language_override?: string;
|
3161 | textIndexVersion?: number;
|
3162 | '2dsphereIndexVersion'?: number;
|
3163 | bits?: number;
|
3164 | min?: number;
|
3165 | max?: number;
|
3166 | bucketSize?: number;
|
3167 | collation?: CollationDocument;
|
3168 | }
|