@kravc/dos 1.11.7 → 1.11.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Document.js +13 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "1.11.7",
3
+ "version": "1.11.9",
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
@@ -154,6 +154,8 @@ class Document extends Component {
154
154
  }
155
155
 
156
156
  static async index(context, query = {}, options = {}) {
157
+ this._extendWithPartition(context, query)
158
+
157
159
  let { items, ...rest } = await this._index(query, options)
158
160
 
159
161
  const objects = items.map(item => new this(context, item))
@@ -174,6 +176,8 @@ class Document extends Component {
174
176
  }
175
177
 
176
178
  static async indexAll(context, query = {}, options = {}) {
179
+ this._extendWithPartition(context, query)
180
+
177
181
  let { items, ...rest } = await this._indexAll(query, options)
178
182
 
179
183
  const objects = items.map(item => new this(context, item))
@@ -203,11 +207,13 @@ class Document extends Component {
203
207
 
204
208
  /* NOTE: ensure that document to be updated exists and save it in the
205
209
  context so can be referenced in the after action helper */
206
- if (!originalDocument) {
210
+ if (originalDocument) {
211
+ this._extendWithPartition(context, query)
212
+
213
+ } else {
207
214
  originalDocument = await this.read(context, query)
208
- }
209
215
 
210
- this._extendWithPartition(context, query)
216
+ }
211
217
 
212
218
  const updatedItem = await this._update(query, mutation)
213
219
 
@@ -243,8 +249,11 @@ class Document extends Component {
243
249
  /* NOTE: ensure that document to be removed exists and save it in the
244
250
  context so can be referenced in the after action helper */
245
251
  const originalDocument = await this.read(context, query)
252
+ const hasQueryPartition = !!query.partition
246
253
 
247
- this._extendWithPartition(context, query)
254
+ if (!hasQueryPartition) {
255
+ this._extendWithPartition(context, query)
256
+ }
248
257
 
249
258
  await this._delete(query, context)
250
259