1 |
|
2 |
|
3 | declare module "mongoose" {
|
4 | interface ListOptions {
|
5 | filter?: object;
|
6 | lean?: boolean;
|
7 | limit?: number;
|
8 | offset?: number;
|
9 | populate?: string | [string];
|
10 | select?: string | [string];
|
11 | sort?: string | [string];
|
12 | group?: string | [string];
|
13 | }
|
14 |
|
15 | interface Model<T extends Document>
|
16 | extends NodeJS.EventEmitter,
|
17 | ModelProperties {
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | get(id: string, populate?: string): Promise<T>;
|
25 |
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | upsert(id: string, update: T): Promise<T>;
|
33 |
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | list(opt?: ListOptions): Promise<Array<T>>;
|
40 |
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 | count(filter?: object): Promise<number>;
|
47 |
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 | softDelete(id: string): Promise<T>;
|
54 | }
|
55 |
|
56 | interface Document
|
57 | extends MongooseDocument,
|
58 | NodeJS.EventEmitter,
|
59 | ModelProperties {
|
60 | |
61 |
|
62 |
|
63 |
|
64 | softDelete(): Promise<this>;
|
65 | |
66 |
|
67 |
|
68 |
|
69 | restore(): Promise<this>;
|
70 | }
|
71 | }
|
72 |
|
73 | declare module "@36node/mongoose-helper" {
|
74 | import mongoose = require("mongoose");
|
75 |
|
76 | |
77 |
|
78 |
|
79 | export function helper(schema: mongoose.Schema, options?: object): void;
|
80 | export const defaultOptions = {
|
81 | timestamps: true,
|
82 | toJSON: {
|
83 | virtuals: true,
|
84 | },
|
85 | toObject: {
|
86 | virtuals: true,
|
87 | },
|
88 | };
|
89 | }
|