@kravc/dos 1.9.1 → 1.9.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
package/src/Document.js CHANGED
@@ -150,8 +150,18 @@ class Document extends Component {
150
150
  return { objects, ...rest }
151
151
  }
152
152
 
153
- static _index() {
154
- const items = Object.values(STORE[this.name] || {}).map(cloneDeep)
153
+ static async indexAll(context, query, options) {
154
+ return this.index(context, query, options)
155
+ }
156
+
157
+ static _index(query) {
158
+ const filter = item =>
159
+ Object.keys(query).every(key => item[key] === query[key])
160
+
161
+ const items = Object
162
+ .values(STORE[this.name] || {})
163
+ .filter(filter)
164
+ .map(cloneDeep)
155
165
 
156
166
  return { items, count: items.length }
157
167
  }
@@ -180,6 +180,9 @@ describe('Document', () => {
180
180
 
181
181
  expect(result.objects.length).to.eql(3)
182
182
  expect(result.count).to.eql(3)
183
+
184
+ result = await Profile.indexAll(context, { name: 'Dasha' })
185
+ expect(result.count).to.eql(1)
183
186
  })
184
187
  })
185
188