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