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