UNPKG

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