dynoquery 0.1.22 → 0.1.24

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/README.md CHANGED
@@ -371,6 +371,7 @@ await johnMeta.save();
371
371
  - `create(data?, indices?)`: Persists the item as a new record with the provided data. Supports GSI indices and internal `conditionBuilder`.
372
372
  - `update(data, indices?)`: Partial update of the item. Supports GSI indices and internal `conditionBuilder`.
373
373
  - `save()`: Persists the current state of the item. Uses indices attached via `setIndex()` and internal `conditionBuilder`.
374
+ - `getData()`: Returns a clean data object containing only the database attributes (filters out internal state and methods).
374
375
  - `setIndex(indices)`: Attaches one or more `IndexQuery` objects to the item.
375
376
  - `setFilter(builder)`: Sets a filter expression builder for the item.
376
377
  - `setCondition(builder)`: Sets a condition for the item using an `ExpressionBuilder`.
package/dist/index.js CHANGED
@@ -181,21 +181,7 @@ class DynoQuery {
181
181
  });
182
182
  }
183
183
  else {
184
- const dataToSave = {};
185
- for (const key in item) {
186
- if (Object.prototype.hasOwnProperty.call(item, key) &&
187
- ![
188
- "_indices",
189
- "_partition",
190
- "_skValue",
191
- "_toBeDeleted",
192
- "_filterBuilder",
193
- "_conditionBuilder",
194
- ].includes(key) &&
195
- typeof item[key] !== "function") {
196
- dataToSave[key] = item[key];
197
- }
198
- }
184
+ const dataToSave = item.getData();
199
185
  // Ensure PK and SK are in the data
200
186
  dataToSave[this.pkName] = partition.getPkValue();
201
187
  dataToSave[this.skName] = skValue;
@@ -314,21 +300,7 @@ class DynoQuery {
314
300
  };
315
301
  }
316
302
  else {
317
- const dataToSave = {};
318
- for (const key in item) {
319
- if (Object.prototype.hasOwnProperty.call(item, key) &&
320
- ![
321
- "_indices",
322
- "_partition",
323
- "_skValue",
324
- "_toBeDeleted",
325
- "_filterBuilder",
326
- "_conditionBuilder",
327
- ].includes(key) &&
328
- typeof item[key] !== "function") {
329
- dataToSave[key] = item[key];
330
- }
331
- }
303
+ const dataToSave = item.getData();
332
304
  // Ensure PK and SK are in the data
333
305
  dataToSave[this.pkName] = pkValue;
334
306
  dataToSave[this.skName] = skValue;
package/dist/partition.js CHANGED
@@ -20,17 +20,29 @@ class Item {
20
20
  const self = this;
21
21
  return new Proxy(this, {
22
22
  get(target, prop, receiver) {
23
- if (prop === "save") {
23
+ if (prop === "getData") {
24
24
  return () => {
25
- const dataToSave = {};
25
+ const data = {};
26
26
  for (const key in target) {
27
27
  if (Object.prototype.hasOwnProperty.call(target, key) &&
28
- !["_indices", "_partition", "_skValue", "_toBeDeleted", "_filterBuilder", "_conditionBuilder"].includes(key) &&
28
+ ![
29
+ "_indices",
30
+ "_partition",
31
+ "_skValue",
32
+ "_toBeDeleted",
33
+ "_filterBuilder",
34
+ "_conditionBuilder",
35
+ ].includes(key) &&
29
36
  typeof target[key] !== "function") {
30
- dataToSave[key] = target[key];
37
+ data[key] = target[key];
31
38
  }
32
39
  }
33
- return partition.update(skValue, dataToSave, self._indices, {
40
+ return data;
41
+ };
42
+ }
43
+ if (prop === "save") {
44
+ return () => {
45
+ return partition.update(skValue, receiver.getData(), self._indices, {
34
46
  conditionBuilder: self._conditionBuilder,
35
47
  });
36
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynoquery",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/devspikejs/dynoquery.git"