1 |
|
2 | declare module 'mongoose' {
|
3 | import mongodb = require('mongodb');
|
4 | import bson = require('bson');
|
5 |
|
6 | class NativeBuffer extends Buffer {}
|
7 |
|
8 | namespace Types {
|
9 | class Array<T> extends global.Array<T> {
|
10 |
|
11 | $pop(): T;
|
12 |
|
13 |
|
14 | $shift(): T;
|
15 |
|
16 |
|
17 | addToSet(...args: any[]): any[];
|
18 |
|
19 | isMongooseArray: true;
|
20 |
|
21 |
|
22 | nonAtomicPush(...args: any[]): number;
|
23 |
|
24 |
|
25 | push(...args: any[]): number;
|
26 |
|
27 | |
28 |
|
29 |
|
30 |
|
31 |
|
32 | pull(...args: any[]): this;
|
33 |
|
34 | |
35 |
|
36 |
|
37 | remove(...args: any[]): this;
|
38 |
|
39 |
|
40 | set(index: number, val: T): this;
|
41 |
|
42 |
|
43 | shift(): T;
|
44 |
|
45 |
|
46 | toObject(options?: ToObjectOptions): any;
|
47 | toObject<T>(options?: ToObjectOptions<T>): T;
|
48 |
|
49 |
|
50 | unshift(...args: any[]): number;
|
51 | }
|
52 |
|
53 | class Buffer extends NativeBuffer {
|
54 |
|
55 | subtype(subtype: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 128 | ToObjectOptions): void;
|
56 |
|
57 |
|
58 | toObject(subtype?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 128): mongodb.Binary;
|
59 | }
|
60 |
|
61 | class Decimal128 extends mongodb.Decimal128 { }
|
62 |
|
63 | class DocumentArray<T> extends Types.Array<T extends Types.Subdocument ? T : Types.Subdocument<InferId<T>, any, T> & T> {
|
64 |
|
65 | constructor(values: AnyObject[]);
|
66 |
|
67 | isMongooseDocumentArray: true;
|
68 |
|
69 | /** Creates a subdocument casted to this schema. */
|
70 | create(obj: any): T extends Types.Subdocument ? T : Types.Subdocument<InferId<T>> & T;
|
71 |
|
72 | /** Searches array items for the first document with a matching _id. */
|
73 | id(id: any): (T extends Types.Subdocument ? T : Types.Subdocument<InferId<T>> & T) | null;
|
74 |
|
75 | push(...args: (AnyKeys<T> & AnyObject)[]): number;
|
76 | }
|
77 |
|
78 | class Map<V> extends global.Map<string, V> {
|
79 |
|
80 | toObject(options?: ToObjectOptions & { flattenMaps?: boolean }): any;
|
81 | }
|
82 |
|
83 | class ObjectId extends mongodb.ObjectId {
|
84 | }
|
85 |
|
86 | class Subdocument<IdType = unknown, TQueryHelpers = any, DocType = any> extends Document<IdType, TQueryHelpers, DocType> {
|
87 | $isSingleNested: true;
|
88 |
|
89 |
|
90 | ownerDocument(): Document;
|
91 |
|
92 |
|
93 | parent(): Document;
|
94 |
|
95 |
|
96 | $parent(): Document;
|
97 | }
|
98 |
|
99 | class ArraySubdocument<IdType = any, TQueryHelpers = unknown, DocType = unknown> extends Subdocument<IdType, TQueryHelpers, DocType> {
|
100 |
|
101 | parentArray(): Types.DocumentArray<unknown>;
|
102 | }
|
103 |
|
104 | class UUID extends bson.UUID {}
|
105 | }
|
106 | }
|