dynoquery 0.1.16 → 0.1.17

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
@@ -66,7 +66,7 @@ async function userExample() {
66
66
 
67
67
  #### Second-Level Objects (Single-Row Operations)
68
68
 
69
- For a more flexible way to work with individual rows, you can use `draft()` and `get()` to obtain an `Item` object, then call `create()`, `update()`, or `save()` on it directly.
69
+ For a more flexible way to work with individual rows, you can use `draft()` and `get()` to obtain an `Item` object, then call `create()`, `update()`, or `save()` on it directly. You can also use a shorthand by passing a second argument to your model function (as shown in the examples below).
70
70
 
71
71
  ```typescript
72
72
  const john = db.User('john@example.com');
@@ -94,7 +94,10 @@ await johnFriend1.update({ Name: 'Alice', rank: 1 });
94
94
  const johnPref = john.draft('PREF', { theme: 'dark' });
95
95
  await johnPref.save();
96
96
 
97
- ````
97
+ // 6. Shorthand access (returns an Item object directly)
98
+ const johnMeta = db.User('john@example.com', 'METADATA');
99
+ await johnMeta.update({ name: 'John Doe' });
100
+ ```
98
101
 
99
102
  ### 2. Global Secondary Indexes (findBy)
100
103
 
@@ -153,7 +156,7 @@ await db.Product('p123').update('INFO', { price: 45 }, [electronics]);
153
156
  #### Using Item.create() and Item.update()
154
157
  ```typescript
155
158
  const electronics = db.findByCategory('ELECTRONICS', 'RANK#1');
156
- const mouse = db.Product('p123').draft('INFO');
159
+ const mouse = db.Product('p123', 'INFO');
157
160
 
158
161
  // Pass data and indices directly to create()
159
162
  await mouse.create({
@@ -170,7 +173,7 @@ You can also use `setIndex()` to attach indices to an item so they are used auto
170
173
 
171
174
  ```typescript
172
175
  const electronics = db.findByCategory('ELECTRONICS', 'RANK#1');
173
- const mouse = db.Product('p123').draft('INFO');
176
+ const mouse = db.Product('p123', 'INFO');
174
177
 
175
178
  mouse.setIndex(electronics);
176
179
  mouse.price = 50;
@@ -232,6 +235,8 @@ if (token) {
232
235
  - `delete(params)`: Low-level DeleteCommand wrapper.
233
236
  - `query(params)`: Low-level QueryCommand wrapper.
234
237
  - `scan(params)`: Low-level ScanCommand wrapper.
238
+ - `[ModelName](id, skValue?)`: Returns a `Partition` instance for the given ID. If `skValue` is provided, returns an `Item` object directly.
239
+ - `findBy[IndexName](id, skValue?)`: Returns an `IndexQuery` instance.
235
240
 
236
241
  ### Partition
237
242
  - `get(sk)`: Fetches data for a specific Sort Key value (returns a Promise).
package/dist/index.js CHANGED
@@ -55,8 +55,12 @@ class DynoQuery {
55
55
  if (models) {
56
56
  this.registeredModels = models;
57
57
  Object.entries(models).forEach(([name, def]) => {
58
- this[name] = (id) => {
59
- return new partition_1.Partition(this, { pkPrefix: this.globalPkPrefix + def.pkPrefix }, id);
58
+ this[name] = (id, sk) => {
59
+ const partition = new partition_1.Partition(this, { pkPrefix: this.globalPkPrefix + def.pkPrefix }, id);
60
+ if (sk) {
61
+ return partition.draft(sk);
62
+ }
63
+ return partition;
60
64
  };
61
65
  });
62
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynoquery",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/devspikejs/dynoquery.git"