express-toolkit 1.0.1 → 1.0.2
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 -6
package/package.json
CHANGED
package/src/controller.js
CHANGED
|
@@ -57,12 +57,13 @@ class Controller {
|
|
|
57
57
|
delete query.sortorder
|
|
58
58
|
delete query.fields
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const docs = await this.Model
|
|
61
61
|
.find(query, projection)
|
|
62
62
|
.sort(sort)
|
|
63
63
|
.skip(skip)
|
|
64
64
|
.limit(limit)
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
return docs.map(doc => doc.toJSON())
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -72,11 +73,11 @@ class Controller {
|
|
|
72
73
|
async findOne (query) {
|
|
73
74
|
const projection = getProjection(query)
|
|
74
75
|
delete query.fields
|
|
75
|
-
const instance = await this.Model.findOne(query, projection)
|
|
76
|
+
const instance = await this.Model.findOne(query, projection)
|
|
76
77
|
if (instance === null) {
|
|
77
78
|
throw new Errors.NotFound()
|
|
78
79
|
} else {
|
|
79
|
-
return instance
|
|
80
|
+
return instance.toJSON()
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
@@ -89,12 +90,12 @@ class Controller {
|
|
|
89
90
|
query[this.id] = id
|
|
90
91
|
const projection = getProjection(query)
|
|
91
92
|
delete query.fields
|
|
92
|
-
const instance = await this.Model.findOne(query, projection)
|
|
93
|
+
const instance = await this.Model.findOne(query, projection)
|
|
93
94
|
|
|
94
95
|
if (instance === null) {
|
|
95
96
|
throw new Errors.NotFound()
|
|
96
97
|
} else {
|
|
97
|
-
return instance
|
|
98
|
+
return instance.toJSON()
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|