@kaspernj/api-maker 1.0.131 → 1.0.132
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/base-model.cjs +0 -1
- package/src/collection.cjs +13 -5
package/package.json
CHANGED
package/src/base-model.cjs
CHANGED
|
@@ -6,7 +6,6 @@ const {digg} = require("diggerize")
|
|
|
6
6
|
const FormDataObjectizer = require("form-data-objectizer")
|
|
7
7
|
const inflection = require("inflection")
|
|
8
8
|
const ModelName = require("./model-name.cjs")
|
|
9
|
-
const ModelsResponseReader = require("./models-response-reader.cjs")
|
|
10
9
|
const NotLoadedError = require("./not-loaded-error.cjs")
|
|
11
10
|
const objectToFormData = require("object-to-formdata").serialize
|
|
12
11
|
const Services = require("./services.cjs")
|
package/src/collection.cjs
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = class ApiMakerCollection {
|
|
|
37
37
|
async count () {
|
|
38
38
|
const response = await this.clone()._merge({count: true})._response()
|
|
39
39
|
|
|
40
|
-
return response
|
|
40
|
+
return digg(response, "count")
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
distinct () {
|
|
@@ -146,7 +146,11 @@ module.exports = class ApiMakerCollection {
|
|
|
146
146
|
async result () {
|
|
147
147
|
const response = await this._response()
|
|
148
148
|
const models = digg(response, "collection")
|
|
149
|
+
|
|
150
|
+
this._addCollectionToModels(models)
|
|
151
|
+
|
|
149
152
|
const result = new Result({collection: this, models, response})
|
|
153
|
+
|
|
150
154
|
return result
|
|
151
155
|
}
|
|
152
156
|
|
|
@@ -200,10 +204,7 @@ module.exports = class ApiMakerCollection {
|
|
|
200
204
|
const response = await this._response()
|
|
201
205
|
const models = digg(response, "collection")
|
|
202
206
|
|
|
203
|
-
|
|
204
|
-
for(const model of models) {
|
|
205
|
-
model.collection = this
|
|
206
|
-
}
|
|
207
|
+
this._addCollectionToModels(models)
|
|
207
208
|
|
|
208
209
|
return models
|
|
209
210
|
}
|
|
@@ -220,6 +221,13 @@ module.exports = class ApiMakerCollection {
|
|
|
220
221
|
return new ApiMakerCollection(this.args, clonedQueryArgs)
|
|
221
222
|
}
|
|
222
223
|
|
|
224
|
+
// This is needed when reloading a version of the model with the same selected attributes and preloads
|
|
225
|
+
_addCollectionToModels(models) {
|
|
226
|
+
for(const model of models) {
|
|
227
|
+
model.collection = this
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
223
231
|
_merge (newQueryArgs) {
|
|
224
232
|
merge(this.queryArgs, newQueryArgs)
|
|
225
233
|
|