1 | declare module 'mongoose' {
|
2 | import stream = require('stream');
|
3 |
|
4 | interface MongooseOptions {
|
5 | /**
|
6 | * Set to `true` to set `allowDiskUse` to true to all aggregation operations by default.
|
7 | *
|
8 | * @default false
|
9 | */
|
10 | allowDiskUse?: boolean;
|
11 | /**
|
12 | * Set to `false` to skip applying global plugins to child schemas.
|
13 | *
|
14 | * @default true
|
15 | */
|
16 | applyPluginsToChildSchemas?: boolean;
|
17 |
|
18 | /**
|
19 | * Set to `true` to apply global plugins to discriminator schemas.
|
20 | * This typically isn't necessary because plugins are applied to the base schema and
|
21 | * discriminators copy all middleware, methods, statics, and properties from the base schema.
|
22 | *
|
23 | * @default false
|
24 | */
|
25 | applyPluginsToDiscriminators?: boolean;
|
26 |
|
27 | /**
|
28 | * autoCreate is `true` by default unless readPreference is secondary or secondaryPreferred,
|
29 | * which means Mongoose will attempt to create every model's underlying collection before
|
30 | * creating indexes. If readPreference is secondary or secondaryPreferred, Mongoose will
|
31 | * default to false for both autoCreate and autoIndex because both createCollection() and
|
32 | * createIndex() will fail when connected to a secondary.
|
33 | */
|
34 | autoCreate?: boolean;
|
35 |
|
36 | /**
|
37 | * Set to `false` to disable automatic index creation for all models associated with this Mongoose instance.
|
38 | *
|
39 | * @default true
|
40 | */
|
41 | autoIndex?: boolean;
|
42 |
|
43 | /**
|
44 | * enable/disable mongoose's buffering mechanism for all connections and models.
|
45 | *
|
46 | * @default true
|
47 | */
|
48 | bufferCommands?: boolean;
|
49 |
|
50 | /**
|
51 | * If bufferCommands is on, this option sets the maximum amount of time Mongoose
|
52 | * buffering will wait before throwing an error.
|
53 | * If not specified, Mongoose will use 10000 (10 seconds).
|
54 | *
|
55 | * @default 10000
|
56 | */
|
57 | bufferTimeoutMS?: number;
|
58 |
|
59 | /**
|
60 | * Set to `true` to `clone()` all schemas before compiling into a model.
|
61 | *
|
62 | * @default false
|
63 | */
|
64 | cloneSchemas?: boolean;
|
65 |
|
66 | /**
|
67 | * Set to `false` to disable the creation of the initial default connection.
|
68 | *
|
69 | * @default true
|
70 | */
|
71 | createInitialConnection?: boolean;
|
72 |
|
73 | /**
|
74 | * If `true`, prints the operations mongoose sends to MongoDB to the console.
|
75 | * If a writable stream is passed, it will log to that stream, without colorization.
|
76 | * If a callback function is passed, it will receive the collection name, the method
|
77 | * name, then all arguments passed to the method. For example, if you wanted to
|
78 | * replicate the default logging, you could output from the callback
|
79 | * `Mongoose: ${collectionName}.${methodName}(${methodArgs.join(', ')})`.
|
80 | *
|
81 | * @default false
|
82 | */
|
83 | debug?:
|
84 | | boolean
|
85 | | { color?: boolean; shell?: boolean; }
|
86 | | stream.Writable
|
87 | | ((collectionName: string, methodName: string, ...methodArgs: any[]) => void);
|
88 |
|
89 | /**
|
90 | * If `true`, adds a `id` virtual to all schemas unless overwritten on a per-schema basis.
|
91 | * @defaultValue true
|
92 | */
|
93 | id?: boolean;
|
94 |
|
95 | /**
|
96 | * If `false`, it will change the `createdAt` field to be [`immutable: false`](https://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-immutable)
|
97 | * which means you can update the `createdAt`.
|
98 | *
|
99 | * @default true
|
100 | */
|
101 | 'timestamps.createdAt.immutable'?: boolean
|
102 |
|
103 | /** If set, attaches [maxTimeMS](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/) to every query */
|
104 | maxTimeMS?: number;
|
105 |
|
106 | /**
|
107 | * Mongoose adds a getter to MongoDB ObjectId's called `_id` that
|
108 | * returns `this` for convenience with populate. Set this to false to remove the getter.
|
109 | *
|
110 | * @default true
|
111 | */
|
112 | objectIdGetter?: boolean;
|
113 |
|
114 | /**
|
115 | * Set to `true` to default to overwriting models with the same name when calling
|
116 | * `mongoose.model()`, as opposed to throwing an `OverwriteModelError`.
|
117 | *
|
118 | * @default false
|
119 | */
|
120 | overwriteModels?: boolean;
|
121 |
|
122 | /**
|
123 | * If `false`, changes the default `returnOriginal` option to `findOneAndUpdate()`,
|
124 | * `findByIdAndUpdate`, and `findOneAndReplace()` to false. This is equivalent to
|
125 | * setting the `new` option to `true` for `findOneAndX()` calls by default. Read our
|
126 | * `findOneAndUpdate()` [tutorial](https://mongoosejs.com/docs/tutorials/findoneandupdate.html)
|
127 | * for more information.
|
128 | *
|
129 | * @default true
|
130 | */
|
131 | returnOriginal?: boolean;
|
132 |
|
133 | /**
|
134 | * Set to true to enable [update validators](
|
135 | * https://mongoosejs.com/docs/validation.html#update-validators
|
136 | * ) for all validators by default.
|
137 | *
|
138 | * @default false
|
139 | */
|
140 | runValidators?: boolean;
|
141 |
|
142 | /**
|
143 | * Sanitizes query filters against [query selector injection attacks](
|
144 | * https://thecodebarbarian.com/2014/09/04/defending-against-query-selector-injection-attacks.html
|
145 | * ) by wrapping any nested objects that have a property whose name starts with $ in a $eq.
|
146 | */
|
147 | sanitizeFilter?: boolean;
|
148 |
|
149 | sanitizeProjection?: boolean;
|
150 |
|
151 | /**
|
152 | * Set to false to opt out of Mongoose adding all fields that you `populate()`
|
153 | * to your `select()`. The schema-level option `selectPopulatedPaths` overwrites this one.
|
154 | *
|
155 | * @default true
|
156 | */
|
157 | selectPopulatedPaths?: boolean;
|
158 |
|
159 | /**
|
160 | * Mongoose also sets defaults on update() and findOneAndUpdate() when the upsert option is
|
161 | * set by adding your schema's defaults to a MongoDB $setOnInsert operator. You can disable
|
162 | * this behavior by setting the setDefaultsOnInsert option to false.
|
163 | *
|
164 | * @default true
|
165 | */
|
166 | setDefaultsOnInsert?: boolean;
|
167 |
|
168 | /**
|
169 | * Sets the default strict mode for schemas.
|
170 | * May be `false`, `true`, or `'throw'`.
|
171 | *
|
172 | * @default true
|
173 | */
|
174 | strict?: boolean | 'throw';
|
175 |
|
176 | /**
|
177 | * Set to `false` to allow populating paths that aren't in the schema.
|
178 | *
|
179 | * @default true
|
180 | */
|
181 | strictPopulate?: boolean;
|
182 |
|
183 | /**
|
184 | * Sets the default [strictQuery](https://mongoosejs.com/docs/guide.html#strictQuery) mode for schemas.
|
185 | * May be `false`, `true`, or `'throw'`.
|
186 | *
|
187 | * @default false
|
188 | */
|
189 | strictQuery?: boolean | 'throw';
|
190 |
|
191 | /**
|
192 | * Overwrites default objects to `toJSON()`, for determining how Mongoose
|
193 | * documents get serialized by `JSON.stringify()`
|
194 | *
|
195 | * @default { transform: true, flattenDecimals: true }
|
196 | */
|
197 | toJSON?: ToObjectOptions;
|
198 |
|
199 | /**
|
200 | * Overwrites default objects to `toObject()`
|
201 | *
|
202 | * @default { transform: true, flattenDecimals: true }
|
203 | */
|
204 | toObject?: ToObjectOptions;
|
205 |
|
206 | /**
|
207 | * Set to true to make Mongoose use Node.js' built-in AsyncLocalStorage (Node >= 16.0.0)
|
208 | * to set `session` option on all operations within a `connection.transaction(fn)` call
|
209 | * by default. Defaults to false.
|
210 | */
|
211 | transactionAsyncLocalStorage?: boolean;
|
212 |
|
213 | /**
|
214 | * If `true`, convert any aliases in filter, projection, update, and distinct
|
215 | * to their database property names. Defaults to false.
|
216 | */
|
217 | translateAliases?: boolean;
|
218 | }
|
219 | }
|
220 |
|
\ | No newline at end of file |