express-toolkit 0.8.3 → 1.0.1

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.3",
3
+ "version": "1.0.1",
4
4
  "files": [
5
5
  "index.js",
6
6
  "src/"
package/src/controller.js CHANGED
@@ -62,6 +62,7 @@ class Controller {
62
62
  .sort(sort)
63
63
  .skip(skip)
64
64
  .limit(limit)
65
+ .lean()
65
66
  }
66
67
 
67
68
  /**
@@ -71,7 +72,7 @@ class Controller {
71
72
  async findOne (query) {
72
73
  const projection = getProjection(query)
73
74
  delete query.fields
74
- const instance = await this.Model.findOne(query, projection)
75
+ const instance = await this.Model.findOne(query, projection).lean()
75
76
  if (instance === null) {
76
77
  throw new Errors.NotFound()
77
78
  } else {
@@ -88,7 +89,7 @@ class Controller {
88
89
  query[this.id] = id
89
90
  const projection = getProjection(query)
90
91
  delete query.fields
91
- const instance = await this.Model.findOne(query, projection)
92
+ const instance = await this.Model.findOne(query, projection).lean()
92
93
 
93
94
  if (instance === null) {
94
95
  throw new Errors.NotFound()
@@ -223,7 +224,8 @@ class Controller {
223
224
 
224
225
  return instance.toJSON()
225
226
  } else {
226
- return instance.save()
227
+ const doc = await instance.save()
228
+ return doc.toJSON()
227
229
  }
228
230
  }
229
231
 
@@ -250,7 +252,8 @@ class Controller {
250
252
  throw new Errors.BadRequest(validationError.message)
251
253
  }
252
254
 
253
- return instance.save()
255
+ const doc = await instance.save()
256
+ return doc.toJSON()
254
257
  }
255
258
 
256
259
  /**
@@ -308,7 +311,7 @@ class Controller {
308
311
 
309
312
  await this.Model.updateOne(query, updatedInstance.toObject())
310
313
 
311
- return updatedInstance
314
+ return updatedInstance.toJSON()
312
315
  }
313
316
 
314
317
  /**