express-toolkit 0.8.3 → 1.0.0
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.
- package/package.json +1 -1
- package/src/controller.js +7 -5
package/package.json
CHANGED
package/src/controller.js
CHANGED
|
@@ -71,7 +71,7 @@ class Controller {
|
|
|
71
71
|
async findOne (query) {
|
|
72
72
|
const projection = getProjection(query)
|
|
73
73
|
delete query.fields
|
|
74
|
-
const instance = await this.Model.findOne(query, projection)
|
|
74
|
+
const instance = await this.Model.findOne(query, projection).lean()
|
|
75
75
|
if (instance === null) {
|
|
76
76
|
throw new Errors.NotFound()
|
|
77
77
|
} else {
|
|
@@ -88,7 +88,7 @@ class Controller {
|
|
|
88
88
|
query[this.id] = id
|
|
89
89
|
const projection = getProjection(query)
|
|
90
90
|
delete query.fields
|
|
91
|
-
const instance = await this.Model.findOne(query, projection)
|
|
91
|
+
const instance = await this.Model.findOne(query, projection).lean()
|
|
92
92
|
|
|
93
93
|
if (instance === null) {
|
|
94
94
|
throw new Errors.NotFound()
|
|
@@ -223,7 +223,8 @@ class Controller {
|
|
|
223
223
|
|
|
224
224
|
return instance.toJSON()
|
|
225
225
|
} else {
|
|
226
|
-
|
|
226
|
+
const doc = await instance.save()
|
|
227
|
+
return doc.toJSON()
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
|
|
@@ -250,7 +251,8 @@ class Controller {
|
|
|
250
251
|
throw new Errors.BadRequest(validationError.message)
|
|
251
252
|
}
|
|
252
253
|
|
|
253
|
-
|
|
254
|
+
const doc = await instance.save()
|
|
255
|
+
return doc.toJSON()
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/**
|
|
@@ -308,7 +310,7 @@ class Controller {
|
|
|
308
310
|
|
|
309
311
|
await this.Model.updateOne(query, updatedInstance.toObject())
|
|
310
312
|
|
|
311
|
-
return updatedInstance
|
|
313
|
+
return updatedInstance.toJSON()
|
|
312
314
|
}
|
|
313
315
|
|
|
314
316
|
/**
|