dynoquery 0.1.8 → 0.1.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.
package/README.md CHANGED
@@ -31,9 +31,9 @@ const db = new DynoQuery({
31
31
  models: {
32
32
  User: { pkPrefix: 'USER#' }, // TENANT#A#USER#
33
33
  },
34
- indexes: {
34
+ findBy: {
35
35
  // TENANT#A#CAT#
36
- ByCategory: { indexName: 'GSI1', pkPrefix: 'CAT#' } // pkName defaults to GSI1PK, skName defaults to GSI1SK
36
+ Category: { indexName: 'GSI1', pkPrefix: 'CAT#' } // pkName defaults to GSI1PK, skName defaults to GSI1SK
37
37
  }
38
38
  });
39
39
 
@@ -44,7 +44,7 @@ async function example() {
44
44
 
45
45
  // Use registered index
46
46
  // Resulting GSI1PK: TENANT#A#CAT#1
47
- const categories = db.ByCategory('1');
47
+ const categories = db.findByCategory('1');
48
48
  const items = await categories.get('100');
49
49
  const allItems = await categories.getAll();
50
50
 
@@ -67,9 +67,8 @@ async function example() {
67
67
  // Create an item through partition
68
68
  await john.create('PROFILE', { name: 'John Doe', email: 'john@example.com' });
69
69
 
70
- // You can also use getPkValue() to get the generated PK for the partition or index
71
- // This is useful when you need to store it in another attribute (e.g., GSI)
72
- const cat = db.ByCategory('USER');
70
+ // Resulting GSI1PK: TENANT#A#CAT#USER
71
+ const cat = db.findByCategory('USER');
73
72
  await john.create('PROFILE', {
74
73
  name: 'John Doe',
75
74
  email: 'john@example.com',
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export interface DynoQueryConfig {
14
14
  models?: Record<string, {
15
15
  pkPrefix: string;
16
16
  }>;
17
- indexes?: Record<string, {
17
+ findBy?: Record<string, {
18
18
  indexName: string;
19
19
  pkName?: string;
20
20
  skName?: string;
package/dist/index.js CHANGED
@@ -41,7 +41,7 @@ const partition_1 = require("./partition");
41
41
  class DynoQuery {
42
42
  constructor(config = {}) {
43
43
  this.registeredModels = {};
44
- const { tableName, pkName, skName, pkPrefix, models, indexes } = config, clientConfig = __rest(config, ["tableName", "pkName", "skName", "pkPrefix", "models", "indexes"]);
44
+ const { tableName, pkName, skName, pkPrefix, models, findBy } = config, clientConfig = __rest(config, ["tableName", "pkName", "skName", "pkPrefix", "models", "findBy"]);
45
45
  this.client = new client_dynamodb_1.DynamoDBClient(clientConfig);
46
46
  this.docClient = lib_dynamodb_1.DynamoDBDocumentClient.from(this.client, {
47
47
  marshallOptions: {
@@ -60,10 +60,11 @@ class DynoQuery {
60
60
  };
61
61
  });
62
62
  }
63
- if (indexes) {
63
+ if (findBy) {
64
64
  const { IndexQuery } = require("./index-query");
65
- Object.entries(indexes).forEach(([name, def]) => {
66
- this[name] = (id) => {
65
+ Object.entries(findBy).forEach(([name, def]) => {
66
+ const methodName = `findBy${name}`;
67
+ this[methodName] = (id) => {
67
68
  return new IndexQuery(this, {
68
69
  indexName: def.indexName,
69
70
  pkName: def.pkName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynoquery",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/devspikejs/dynoquery.git"