@kravc/dos 1.10.3 → 1.10.5
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
package/src/Document.js
CHANGED
|
@@ -161,10 +161,6 @@ class Document extends Component {
|
|
|
161
161
|
return { objects, ...rest }
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
static async indexAll(context, query, options) {
|
|
165
|
-
return this.index(context, query, options)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
164
|
static _index(query) {
|
|
169
165
|
const filter = item =>
|
|
170
166
|
Object.keys(query).every(key => item[key] === query[key])
|
|
@@ -177,6 +173,18 @@ class Document extends Component {
|
|
|
177
173
|
return { items, count: items.length }
|
|
178
174
|
}
|
|
179
175
|
|
|
176
|
+
static async indexAll(context, query = {}, options = {}) {
|
|
177
|
+
let { items, ...rest } = await this._indexAll(query, options)
|
|
178
|
+
|
|
179
|
+
const objects = items.map(item => new this(context, item))
|
|
180
|
+
|
|
181
|
+
return { objects, ...rest }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static _indexAll(query) {
|
|
185
|
+
return this._index(query)
|
|
186
|
+
}
|
|
187
|
+
|
|
180
188
|
static async update(context, query, mutation, originalDocument = null) {
|
|
181
189
|
mutation = omit(mutation, [ this.idKey, 'createdAt', 'createdBy' ])
|
|
182
190
|
|
package/src/Document.spec.js
CHANGED
|
@@ -183,6 +183,9 @@ describe('Document', () => {
|
|
|
183
183
|
|
|
184
184
|
result = await Profile.indexAll(context, { name: 'Dasha' })
|
|
185
185
|
expect(result.count).to.eql(1)
|
|
186
|
+
|
|
187
|
+
result = await Profile.indexAll(context)
|
|
188
|
+
expect(result.count).to.eql(3)
|
|
186
189
|
})
|
|
187
190
|
})
|
|
188
191
|
|
|
@@ -240,6 +243,10 @@ describe('Document', () => {
|
|
|
240
243
|
const callbacks = {}
|
|
241
244
|
|
|
242
245
|
class CustomProfile extends Profile {
|
|
246
|
+
static getPartition() {
|
|
247
|
+
return 'CustomProfile'
|
|
248
|
+
}
|
|
249
|
+
|
|
243
250
|
static beforeCreate(context, mutation) {
|
|
244
251
|
callbacks.beforeCreate = mutation
|
|
245
252
|
}
|