mongoose 6.2.2 → 6.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,183 @@
1
+ import mongodb = require('mongodb');
2
+
3
+ declare module 'mongoose' {
4
+
5
+ interface SchemaTimestampsConfig {
6
+ createdAt?: boolean | string;
7
+ updatedAt?: boolean | string;
8
+ currentTime?: () => (NativeDate | number);
9
+ }
10
+
11
+ interface SchemaOptions {
12
+ /**
13
+ * By default, Mongoose's init() function creates all the indexes defined in your model's schema by
14
+ * calling Model.createIndexes() after you successfully connect to MongoDB. If you want to disable
15
+ * automatic index builds, you can set autoIndex to false.
16
+ */
17
+ autoIndex?: boolean;
18
+ /**
19
+ * If set to `true`, Mongoose will call Model.createCollection() to create the underlying collection
20
+ * in MongoDB if autoCreate is set to true. Calling createCollection() sets the collection's default
21
+ * collation based on the collation option and establishes the collection as a capped collection if
22
+ * you set the capped schema option.
23
+ */
24
+ autoCreate?: boolean;
25
+ /**
26
+ * By default, mongoose buffers commands when the connection goes down until the driver manages to reconnect.
27
+ * To disable buffering, set bufferCommands to false.
28
+ */
29
+ bufferCommands?: boolean;
30
+ /**
31
+ * If bufferCommands is on, this option sets the maximum amount of time Mongoose buffering will wait before
32
+ * throwing an error. If not specified, Mongoose will use 10000 (10 seconds).
33
+ */
34
+ bufferTimeoutMS?: number;
35
+ /**
36
+ * Mongoose supports MongoDBs capped collections. To specify the underlying MongoDB collection be capped, set
37
+ * the capped option to the maximum size of the collection in bytes.
38
+ */
39
+ capped?: boolean | number | { size?: number; max?: number; autoIndexId?: boolean; };
40
+ /** Sets a default collation for every query and aggregation. */
41
+ collation?: mongodb.CollationOptions;
42
+
43
+ /** The timeseries option to use when creating the model's collection. */
44
+ timeseries?: mongodb.TimeSeriesCollectionOptions;
45
+
46
+ /**
47
+ * Mongoose by default produces a collection name by passing the model name to the utils.toCollectionName
48
+ * method. This method pluralizes the name. Set this option if you need a different name for your collection.
49
+ */
50
+ collection?: string;
51
+ /**
52
+ * When you define a [discriminator](/docs/discriminators.html), Mongoose adds a path to your
53
+ * schema that stores which discriminator a document is an instance of. By default, Mongoose
54
+ * adds an `__t` path, but you can set `discriminatorKey` to overwrite this default.
55
+ *
56
+ * @default '__t'
57
+ */
58
+ discriminatorKey?: string;
59
+
60
+ /**
61
+ * Option for nested Schemas.
62
+ *
63
+ * If true, skip building indexes on this schema's path.
64
+ *
65
+ * @default false
66
+ */
67
+ excludeIndexes?: boolean;
68
+ /**
69
+ * Mongoose assigns each of your schemas an id virtual getter by default which returns the document's _id field
70
+ * cast to a string, or in the case of ObjectIds, its hexString.
71
+ */
72
+ id?: boolean;
73
+ /**
74
+ * Mongoose assigns each of your schemas an _id field by default if one is not passed into the Schema
75
+ * constructor. The type assigned is an ObjectId to coincide with MongoDB's default behavior. If you
76
+ * don't want an _id added to your schema at all, you may disable it using this option.
77
+ */
78
+ _id?: boolean;
79
+ /**
80
+ * Mongoose will, by default, "minimize" schemas by removing empty objects. This behavior can be
81
+ * overridden by setting minimize option to false. It will then store empty objects.
82
+ */
83
+ minimize?: boolean;
84
+ /**
85
+ * Optimistic concurrency is a strategy to ensure the document you're updating didn't change between when you
86
+ * loaded it using find() or findOne(), and when you update it using save(). Set to `true` to enable
87
+ * optimistic concurrency.
88
+ */
89
+ optimisticConcurrency?: boolean;
90
+ /**
91
+ * If `plugin()` called with tags, Mongoose will only apply plugins to schemas that have
92
+ * a matching tag in `pluginTags`
93
+ */
94
+ pluginTags?: string[];
95
+ /**
96
+ * Allows setting query#read options at the schema level, providing us a way to apply default ReadPreferences
97
+ * to all queries derived from a model.
98
+ */
99
+ read?: string;
100
+ /** Allows setting write concern at the schema level. */
101
+ writeConcern?: WriteConcern;
102
+ /** defaults to true. */
103
+ safe?: boolean | { w?: number | string; wtimeout?: number; j?: boolean };
104
+ /**
105
+ * The shardKey option is used when we have a sharded MongoDB architecture. Each sharded collection is
106
+ * given a shard key which must be present in all insert/update operations. We just need to set this
107
+ * schema option to the same shard key and we'll be all set.
108
+ */
109
+ shardKey?: Record<string, unknown>;
110
+ /**
111
+ * The strict option, (enabled by default), ensures that values passed to our model constructor that were not
112
+ * specified in our schema do not get saved to the db.
113
+ */
114
+ strict?: boolean | 'throw';
115
+ /**
116
+ * equal to `strict` by default, may be `false`, `true`, or `'throw'`. Sets the default
117
+ * [strictQuery](https://mongoosejs.com/docs/guide.html#strictQuery) mode for schemas.
118
+ */
119
+ strictQuery?: boolean | 'throw';
120
+ /** Exactly the same as the toObject option but only applies when the document's toJSON method is called. */
121
+ toJSON?: ToObjectOptions;
122
+ /**
123
+ * Documents have a toObject method which converts the mongoose document into a plain JavaScript object.
124
+ * This method accepts a few options. Instead of applying these options on a per-document basis, we may
125
+ * declare the options at the schema level and have them applied to all of the schema's documents by
126
+ * default.
127
+ */
128
+ toObject?: ToObjectOptions;
129
+ /**
130
+ * By default, if you have an object with key 'type' in your schema, mongoose will interpret it as a
131
+ * type declaration. However, for applications like geoJSON, the 'type' property is important. If you want to
132
+ * control which key mongoose uses to find type declarations, set the 'typeKey' schema option.
133
+ */
134
+ typeKey?: string;
135
+
136
+ /**
137
+ * By default, documents are automatically validated before they are saved to the database. This is to
138
+ * prevent saving an invalid document. If you want to handle validation manually, and be able to save
139
+ * objects which don't pass validation, you can set validateBeforeSave to false.
140
+ */
141
+ validateBeforeSave?: boolean;
142
+ /**
143
+ * The versionKey is a property set on each document when first created by Mongoose. This keys value
144
+ * contains the internal revision of the document. The versionKey option is a string that represents
145
+ * the path to use for versioning. The default is '__v'.
146
+ *
147
+ * @default '__v'
148
+ */
149
+ versionKey?: string | boolean;
150
+ /**
151
+ * By default, Mongoose will automatically select() any populated paths for you, unless you explicitly exclude them.
152
+ *
153
+ * @default true
154
+ */
155
+ selectPopulatedPaths?: boolean;
156
+ /**
157
+ * skipVersioning allows excluding paths from versioning (i.e., the internal revision will not be
158
+ * incremented even if these paths are updated). DO NOT do this unless you know what you're doing.
159
+ * For subdocuments, include this on the parent document using the fully qualified path.
160
+ */
161
+ skipVersioning?: {[key: string]: boolean; };
162
+ /**
163
+ * Validation errors in a single nested schema are reported
164
+ * both on the child and on the parent schema.
165
+ * Set storeSubdocValidationError to false on the child schema
166
+ * to make Mongoose only report the parent error.
167
+ */
168
+ storeSubdocValidationError?: boolean;
169
+ /**
170
+ * The timestamps option tells mongoose to assign createdAt and updatedAt fields to your schema. The type
171
+ * assigned is Date. By default, the names of the fields are createdAt and updatedAt. Customize the
172
+ * field names by setting timestamps.createdAt and timestamps.updatedAt.
173
+ */
174
+ timestamps?: boolean | SchemaTimestampsConfig;
175
+
176
+ /**
177
+ * Using `save`, `isNew`, and other Mongoose reserved names as schema path names now triggers a warning, not an error.
178
+ * You can suppress the warning by setting { supressReservedKeysWarning: true } schema options. Keep in mind that this
179
+ * can break plugins that rely on these reserved names.
180
+ */
181
+ supressReservedKeysWarning?: boolean
182
+ }
183
+ }