orm-dynamodb 1.0.1 → 1.0.2

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/README.md +20 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -8,10 +8,10 @@ Lightweight TypeScript decorators for modeling DynamoDB items as classes.
8
8
  ## ✨ Features
9
9
 
10
10
  - 🎯 **Type-safe decorators** for DynamoDB entities with full TypeScript support
11
- - 🔗 **Entity relationships** with `@Link` decorator and automatic link loading
11
+ - 🔗 **Entity relationships** with `@LinkObject` and `@LinkArray` decorators and automatic link loading
12
12
  - 🔄 **Custom serialization** with `@ToDbModel` and `@FromDbModel` transformers
13
13
  - ⏰ **Automatic timestamps** for `createdAt` and `updatedAt`
14
- - 🛠️ **Intuitive API** with `save()`, `update()`, `delete()`, `get()`, and `query()` methods
14
+ - 🛠️ **Intuitive API** with `insert()`, `update()`, `delete()`, `get()`, and `query()` methods
15
15
  - 🚀 **Zero configuration** - works out of the box with AWS SDK v3
16
16
  - 📦 **Tiny footprint** - lightweight with minimal dependencies
17
17
 
@@ -45,7 +45,7 @@ import {
45
45
  Entity,
46
46
  FromDbModel,
47
47
  HashKeyValue,
48
- Link,
48
+ LinkObject,
49
49
  SortKeyValue,
50
50
  ToDbModel
51
51
  } from 'orm-dynamodb';
@@ -90,7 +90,7 @@ class Post extends BaseEntity {
90
90
  title: string;
91
91
  publishedAt: Date | null;
92
92
 
93
- @Link(Author)
93
+ @LinkObject(Author)
94
94
  author: Author | undefined;
95
95
 
96
96
  constructor(slug: string = '', title: string = '', publishedAt: Date | null = null) {
@@ -119,7 +119,7 @@ async function run() {
119
119
  const post = new Post('decorators-with-dynamodb', 'Decorators With DynamoDB', new Date());
120
120
  post.author = new Author('ada-lovelace', 'Ada Lovelace');
121
121
 
122
- await post.save();
122
+ await post.insert();
123
123
 
124
124
  const loaded = await Post.get('decorators-with-dynamodb');
125
125
  await loaded?.loadLinks();
@@ -133,23 +133,30 @@ async function run() {
133
133
  ### Decorators & Classes
134
134
 
135
135
  - **`BaseEntity`** - Base class for all entities with CRUD operations
136
- - **`@Entity(tableName, hashKey, sortKey)`** - Marks a class as a DynamoDB entity
136
+ - **`@Entity(tableName, hashKey, sortKey?, dbClient?)`** - Marks a class as a DynamoDB entity
137
137
  - **`@HashKeyValue`** - Defines the hash key value getter
138
138
  - **`@SortKeyValue`** - Defines the sort key value getter
139
- - **`@Link(EntityClass)`** - Creates a reference to another entity
139
+ - **`@LinkObject(EntityClass, options?)`** - Creates a reference to a single entity (options: `{ inline?: boolean }`)
140
+ - **`@LinkArray(EntityClass, options?)`** - Creates a reference to an array of entities (options: `{ inline?: boolean }`)
140
141
  - **`@ToDbModel`** - Custom serialization when writing to DynamoDB
141
142
  - **`@FromDbModel`** - Custom deserialization when reading from DynamoDB
142
143
 
143
144
  ### Core Methods
144
145
 
145
- **Instance Methods:**
146
- - `save()` - Insert or update the entity
147
- - `update()` - Partial update of the entity
146
+ **Iinsert()` - Insert or update the entity (cascade saves linked entities)
147
+ - `update(attributes)` - Partial update of the entity
148
148
  - `delete()` - Remove the entity from DynamoDB
149
149
  - `loadLinks()` - Load all linked entities
150
150
 
151
151
  **Static Methods:**
152
152
  - `get(sortKeyValue)` - Retrieve a single entity by sort key
153
+ - `query(options)` - Query entities with custom options
154
+ - `queryAll(limit?)` - Query all entities in the partition
155
+ - `queryEquals(sortKeyValue, limit?)` - Query entities with exact sort key match
156
+ - `queryStartsWith(prefix, limit?)` - Query entities with sort key prefix
157
+ - `queryBetween(start, end, limit?)` - Query entities with sort key in range
158
+ - `queryGreaterThan(value, limit?)` - Query entities with sort key greater than value
159
+ - `queryLessThan(value, limit?)` - Query entities with sort key less than valuesort key
153
160
  - `query(options)` - Query entities in the partition
154
161
  - `configure(client)` - Set the DynamoDB client globally
155
162
 
@@ -157,8 +164,10 @@ async function run() {
157
164
 
158
165
  - ✅ Explicit DynamoDB client configuration via `BaseEntity.configure(...)` or `@Entity(..., dbClient)`
159
166
  - ✅ Automatic `createdAt` and `updatedAt` timestamp management
160
- - ✅ Type-safe entity relationships with lazy loading
167
+ - ✅ Type-safe entity relationships with `@LinkObject` and `@LinkArray` decorators
168
+ - ✅ Lazy loading of linked entities with `loadLinks()`
161
169
  - ✅ Custom transformation between domain models and DynamoDB items
170
+ - ✅ Inline and non-inline link storage options
162
171
 
163
172
  ## 🛠️ Development
164
173
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orm-dynamodb",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Lightweight TypeScript decorators for modeling DynamoDB items as classes",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",