express-toolkit 0.8.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-toolkit",
3
- "version": "0.8.2",
3
+ "version": "1.0.0",
4
4
  "files": [
5
5
  "index.js",
6
6
  "src/"
@@ -35,9 +35,9 @@
35
35
  "express"
36
36
  ],
37
37
  "dependencies": {
38
- "express": "^4.17.3",
39
- "json8-patch": "^1.0.4",
40
- "mongoose": "^5.12.3",
38
+ "express": "^4.18.1",
39
+ "json8-patch": "^1.0.6",
40
+ "mongoose": "^6.5.1",
41
41
  "throwable-http-errors": "^2.1.0"
42
42
  },
43
43
  "devDependencies": {
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
- return instance.save()
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
- return instance.save()
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
  /**