UNPKG

1.52 kBTypeScriptView Raw
1declare module 'mongoose' {
2 import mongodb = require('mongodb');
3
4 /*
5 * section collection.js
6 */
7 interface CollectionBase<T extends mongodb.Document> extends mongodb.Collection<T> {
8 /*
9 * Abstract methods. Some of these are already defined on the
10 * mongodb.Collection interface so they've been commented out.
11 */
12 ensureIndex(...args: any[]): any;
13 findAndModify(...args: any[]): any;
14 getIndexes(...args: any[]): any;
15
16 /** The collection name */
17 collectionName: string;
18 /** The Connection instance */
19 conn: Connection;
20 /** The collection name */
21 name: string;
22 }
23
24 /*
25 * section drivers/node-mongodb-native/collection.js
26 */
27 interface Collection<T extends mongodb.Document = mongodb.Document> extends CollectionBase<T> {
28 /**
29 * Collection constructor
30 * @param name name of the collection
31 * @param conn A MongooseConnection instance
32 * @param opts optional collection options
33 */
34 // eslint-disable-next-line @typescript-eslint/no-misused-new
35 new(name: string, conn: Connection, opts?: any): Collection<T>;
36 /** Formatter for debug print args */
37 $format(arg: any, color?: boolean, shell?: boolean): string;
38 /** Debug print helper */
39 $print(name: string, i: string | number, args: any[], color?: boolean, shell?: boolean): void;
40 /** Retrieves information about this collections indexes. */
41 getIndexes(): ReturnType<mongodb.Collection<T>['indexInformation']>;
42 }
43 let Collection: Collection;
44}