dynoquery 0.1.6 → 0.1.7

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
@@ -29,7 +29,7 @@ const db = new DynoQuery({
29
29
  pkPrefix: 'TENANT#A#', // Optional: Global prefix for all partitions (useful for multitenancy)
30
30
  // optional endpoint for local development
31
31
  // endpoint: 'http://localhost:8000'
32
- partitions: {
32
+ models: {
33
33
  User: { pkPrefix: 'USER#' }, // TENANT#A#USER#
34
34
  },
35
35
  indexes: {
@@ -173,7 +173,7 @@ A way to query Global Secondary Indexes.
173
173
  - `batchGetInput(...sks)`: Generates items for batch query.
174
174
  - `batchWriteInput(...items)`: Generates items for batch write.
175
175
  - `batchDeleteInput(...sks)`: Generates items for batch delete.
176
- - Automatically identifies models in results using `__model` and provides `getPartition()` helper.
176
+ - Automatically identifies the model name in results using `__model` (based on registered models) and provides `getPartition()` helper.
177
177
 
178
178
  ## License
179
179
 
@@ -119,9 +119,9 @@ class IndexQuery {
119
119
  const pkValue = item[pkName];
120
120
  if (!pkValue)
121
121
  return item;
122
- const registeredPartitions = this.db.getRegisteredPartitions();
122
+ const registeredModels = this.db.getRegisteredModels();
123
123
  const globalPrefix = this.db.getPkPrefix();
124
- for (const [name, def] of Object.entries(registeredPartitions)) {
124
+ for (const [name, def] of Object.entries(registeredModels)) {
125
125
  const fullPrefix = globalPrefix + def.pkPrefix;
126
126
  if (pkValue.startsWith(fullPrefix)) {
127
127
  // Find the ID by removing the prefix
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export interface DynoQueryConfig {
11
11
  secretAccessKey: string;
12
12
  sessionToken?: string;
13
13
  };
14
- partitions?: Record<string, {
14
+ models?: Record<string, {
15
15
  pkPrefix: string;
16
16
  }>;
17
17
  indexes?: Record<string, {
@@ -34,7 +34,7 @@ export declare class DynoQuery {
34
34
  private globalPkPrefix;
35
35
  private pkName;
36
36
  private skName;
37
- private registeredPartitions;
37
+ private registeredModels;
38
38
  [key: string]: any;
39
39
  constructor(config?: DynoQueryConfig);
40
40
  /**
@@ -73,7 +73,7 @@ export declare class DynoQuery {
73
73
  getPkPrefix(): string;
74
74
  getPkName(): string;
75
75
  getSkName(): string;
76
- getRegisteredPartitions(): Record<string, {
76
+ getRegisteredModels(): Record<string, {
77
77
  pkPrefix: string;
78
78
  }>;
79
79
  }
package/dist/index.js CHANGED
@@ -40,8 +40,8 @@ const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
40
40
  const partition_1 = require("./partition");
41
41
  class DynoQuery {
42
42
  constructor(config = {}) {
43
- this.registeredPartitions = {};
44
- const { tableName, pkName, skName, pkPrefix, partitions, indexes } = config, clientConfig = __rest(config, ["tableName", "pkName", "skName", "pkPrefix", "partitions", "indexes"]);
43
+ this.registeredModels = {};
44
+ const { tableName, pkName, skName, pkPrefix, models, indexes } = config, clientConfig = __rest(config, ["tableName", "pkName", "skName", "pkPrefix", "models", "indexes"]);
45
45
  this.client = new client_dynamodb_1.DynamoDBClient(clientConfig);
46
46
  this.docClient = lib_dynamodb_1.DynamoDBDocumentClient.from(this.client, {
47
47
  marshallOptions: {
@@ -52,9 +52,9 @@ class DynoQuery {
52
52
  this.globalPkPrefix = pkPrefix || "";
53
53
  this.pkName = pkName || "PK";
54
54
  this.skName = skName || "SK";
55
- if (partitions) {
56
- this.registeredPartitions = partitions;
57
- Object.entries(partitions).forEach(([name, def]) => {
55
+ if (models) {
56
+ this.registeredModels = models;
57
+ Object.entries(models).forEach(([name, def]) => {
58
58
  this[name] = (id) => {
59
59
  return new partition_1.Partition(this, { pkPrefix: this.globalPkPrefix + def.pkPrefix }, id);
60
60
  };
@@ -232,8 +232,8 @@ class DynoQuery {
232
232
  getSkName() {
233
233
  return this.skName;
234
234
  }
235
- getRegisteredPartitions() {
236
- return this.registeredPartitions;
235
+ getRegisteredModels() {
236
+ return this.registeredModels;
237
237
  }
238
238
  }
239
239
  exports.DynoQuery = DynoQuery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynoquery",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/devspikejs/dynoquery.git"
@@ -15,6 +15,7 @@
15
15
  "scripts": {
16
16
  "build": "tsc",
17
17
  "test": "jest src",
18
+ "version": "npm run build && git add dist",
18
19
  "prepublishOnly": "npm run build"
19
20
  },
20
21
  "keywords": [