express-restify-mongoose 9.0.3 β 9.0.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.
|
@@ -26,6 +26,7 @@ type Options = {
|
|
|
26
26
|
preRead: RequestHandler | RequestHandler[];
|
|
27
27
|
preUpdate: RequestHandler | RequestHandler[];
|
|
28
28
|
preDelete: RequestHandler | RequestHandler[];
|
|
29
|
+
updateDeep: boolean;
|
|
29
30
|
access?: (req: Request) => Access | Promise<Access>;
|
|
30
31
|
contextFilter: (model: mongoose.Model<unknown>, req: Request, done: (query: mongoose.Model<unknown> | mongoose.Query<unknown, unknown>) => void) => void;
|
|
31
32
|
postCreate?: RequestHandler | RequestHandler[];
|
|
@@ -23,7 +23,7 @@ const defaultOptions = {
|
|
|
23
23
|
version: "/v1",
|
|
24
24
|
idProperty: "_id",
|
|
25
25
|
restify: false,
|
|
26
|
-
allowRegex:
|
|
26
|
+
allowRegex: true,
|
|
27
27
|
runValidators: false,
|
|
28
28
|
readPreference: "primary",
|
|
29
29
|
totalCountHeader: false,
|
|
@@ -37,7 +37,8 @@ const defaultOptions = {
|
|
|
37
37
|
preCreate: [],
|
|
38
38
|
preRead: [],
|
|
39
39
|
preUpdate: [],
|
|
40
|
-
preDelete: []
|
|
40
|
+
preDelete: [],
|
|
41
|
+
updateDeep: true
|
|
41
42
|
};
|
|
42
43
|
const filter = new _resource_filter.Filter();
|
|
43
44
|
function serve(app, model, options = {}) {
|
package/dist/getQuerySchema.js
CHANGED
|
@@ -14,6 +14,7 @@ const PopulateOptionsSchema = _zod.z.object({
|
|
|
14
14
|
match: _zod.z.record(_zod.z.unknown()).optional(),
|
|
15
15
|
options: _zod.z.record(_zod.z.unknown()).optional(),
|
|
16
16
|
select: _zod.z.string().optional(),
|
|
17
|
+
populate: _zod.z.record(_zod.z.unknown()).optional(),
|
|
17
18
|
// Configure populate query to not use strict populate to maintain
|
|
18
19
|
// behavior from Mongoose previous to v6 (unless already configured)
|
|
19
20
|
strictPopulate: _zod.z.boolean().optional().default(false)
|
package/dist/operations.js
CHANGED
|
@@ -241,7 +241,10 @@ function operations(model, options, filter) {
|
|
|
241
241
|
}
|
|
242
242
|
return dst;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
let cleanBody = depopulate(req.body);
|
|
245
|
+
if (options.updateDeep) {
|
|
246
|
+
cleanBody = (0, _moredots.moredots)(cleanBody);
|
|
247
|
+
}
|
|
245
248
|
if (options.findOneAndUpdate) {
|
|
246
249
|
options.contextFilter(contextModel, req, (filteredContext)=>{
|
|
247
250
|
// @ts-expect-error this is fine πΆπ₯
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-restify-mongoose",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.5",
|
|
4
4
|
"description": "Easily create a flexible REST interface for mongoose models",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ReST",
|
|
@@ -71,4 +71,4 @@
|
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": ">=16"
|
|
73
73
|
}
|
|
74
|
-
}
|
|
74
|
+
}
|