dyna-record 0.6.0 → 0.6.1

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 +41 -41
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Dyna-Record
2
2
 
3
- [API Documentation](https://dyna-record.com/)
3
+ [API Documentation](https://docs.dyna-record.com/)
4
4
 
5
5
  [Medium Article](https://medium.com/@drewdavis888/unlock-relational-data-modeling-in-dynamodb-with-dyna-record-5b9cce27c3ce)
6
6
 
@@ -51,9 +51,9 @@ Entities in Dyna-Record represent your DynamoDB table structure and relationship
51
51
 
52
52
  ### Table
53
53
 
54
- [Docs](https://dyna-record.com/functions/Table.html)
54
+ [Docs](https://docs.dyna-record.com/functions/Table.html)
55
55
 
56
- Create a table class that extends [DynaRecord base class](https://dyna-record.com/classes/default.html) and is decorated with the [Table decorator](https://dyna-record.com/functions/Table.html). At a minimum, the table class must define the [PartitionKeyAttribute](https://dyna-record.com/functions/PartitionKeyAttribute.html) and [SortKeyAttribute](https://dyna-record.com/functions/SortKeyAttribute.html).
56
+ Create a table class that extends [DynaRecord base class](https://docs.dyna-record.com/classes/default.html) and is decorated with the [Table decorator](https://docs.dyna-record.com/functions/Table.html). At a minimum, the table class must define the [PartitionKeyAttribute](https://docs.dyna-record.com/functions/PartitionKeyAttribute.html) and [SortKeyAttribute](https://docs.dyna-record.com/functions/SortKeyAttribute.html).
57
57
 
58
58
  #### Basic usage
59
59
 
@@ -108,20 +108,20 @@ abstract class MyTable extends DynaRecord {
108
108
 
109
109
  ### Entity
110
110
 
111
- [Docs](https://dyna-record.com/functions/Entity.html)
111
+ [Docs](https://docs.dyna-record.com/functions/Entity.html)
112
112
 
113
113
  Each entity must extend the Table class. To support single table design patterns, they must extend the same tables class.
114
114
 
115
115
  Each entity **must** declare its `type` property as a string literal matching the class name. This enables compile-time type safety for query filters and return types. Omitting this declaration will produce a compile error at the `@Entity` decorator.
116
116
 
117
- By default, each entity will have [default attributes](https://dyna-record.com/types/_internal_.DefaultFields.html)
117
+ By default, each entity will have [default attributes](https://docs.dyna-record.com/types/_internal_.DefaultFields.html)
118
118
 
119
119
  - The partition key defined on the [table](#table) class
120
120
  - The sort key defined on the [table](#table) class
121
- - [id](https://dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated uuid unless [IdAttribute](<(https://dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
122
- - [type](https://dyna-record.com/classes/default.html#type) - The type of the entity. Value is the entity class name. Must be declared as a string literal via `declare readonly type: "ClassName"`.
123
- - [createdAt](https://dyna-record.com/classes/default.html#createdAt) - The timestamp of when the entity was created
124
- - [updatedAt](https://dyna-record.com/classes/default.html#updatedAt) - Timestamp of when the entity was updated last
121
+ - [id](https://docs.dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated uuid unless [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
122
+ - [type](https://docs.dyna-record.com/classes/default.html#type) - The type of the entity. Value is the entity class name. Must be declared as a string literal via `declare readonly type: "ClassName"`.
123
+ - [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) - The timestamp of when the entity was created
124
+ - [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) - Timestamp of when the entity was updated last
125
125
 
126
126
  ```typescript
127
127
  import { Entity } from "dyna-record";
@@ -147,17 +147,17 @@ Use the attribute decorators below to define attributes on a model. The decorato
147
147
 
148
148
  - Attribute decorators
149
149
 
150
- - [@StringAttribute](https://dyna-record.com/functions/StringAttribute.html)
151
- - [@NumberAttribute](https://dyna-record.com/functions/NumberAttribute.html)
152
- - [@BooleanAttribute](https://dyna-record.com/functions/BooleanAttribute.html)
153
- - [@DateAttribute](https://dyna-record.com/functions/DateAttribute.html)
154
- - [@EnumAttribute](https://dyna-record.com/functions/EnumAttribute.html)
155
- - [@IdAttribute](https://dyna-record.com/functions/IdAttribute.html)
156
- - [@ObjectAttribute](https://dyna-record.com/functions/ObjectAttribute.html)
150
+ - [@StringAttribute](https://docs.dyna-record.com/functions/StringAttribute.html)
151
+ - [@NumberAttribute](https://docs.dyna-record.com/functions/NumberAttribute.html)
152
+ - [@BooleanAttribute](https://docs.dyna-record.com/functions/BooleanAttribute.html)
153
+ - [@DateAttribute](https://docs.dyna-record.com/functions/DateAttribute.html)
154
+ - [@EnumAttribute](https://docs.dyna-record.com/functions/EnumAttribute.html)
155
+ - [@IdAttribute](https://docs.dyna-record.com/functions/IdAttribute.html)
156
+ - [@ObjectAttribute](https://docs.dyna-record.com/functions/ObjectAttribute.html)
157
157
 
158
- - The [alias](https://dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
158
+ - The [alias](https://docs.dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
159
159
  - Set nullable attributes as optional for optimal type safety
160
- - Attempting to remove a non-nullable attribute will result in a [NullConstrainViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
160
+ - Attempting to remove a non-nullable attribute will result in a [NullConstrainViolationError](https://docs.dyna-record.com/classes/NullConstraintViolationError.html)
161
161
 
162
162
  ```typescript
163
163
  import { Entity, Attribute } from "dyna-record";
@@ -251,11 +251,11 @@ The schema must be declared with `as const satisfies ObjectSchema` so TypeScript
251
251
 
252
252
  ### Foreign Keys
253
253
 
254
- Define foreign keys in order to support [@BelongsTo](https://dyna-record.com/functions/BelongsTo.html) relationships. A foreign key is required for [@HasOne](https://dyna-record.com/functions/HasOne.html) and [@HasMany](https://dyna-record.com/functions/HasMany.html) relationships.
254
+ Define foreign keys in order to support [@BelongsTo](https://docs.dyna-record.com/functions/BelongsTo.html) relationships. A foreign key is required for [@HasOne](https://docs.dyna-record.com/functions/HasOne.html) and [@HasMany](https://docs.dyna-record.com/functions/HasMany.html) relationships.
255
255
 
256
- - The [alias](https://dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
256
+ - The [alias](https://docs.dyna-record.com/interfaces/AttributeOptions.html#alias) option allows you to specify the attribute name as it appears in the DynamoDB table, different from your class property name.
257
257
  - Set nullable foreign key attributes as optional for optimal type safety
258
- - Attempting to remove an entity from a non-nullable foreign key will result in a [NullConstrainViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
258
+ - Attempting to remove an entity from a non-nullable foreign key will result in a [NullConstrainViolationError](https://docs.dyna-record.com/classes/NullConstraintViolationError.html)
259
259
  - Always provide the referenced entity class to `@ForeignKeyAttribute` (for example `@ForeignKeyAttribute(() => Customer)`); this allows DynaRecord to enforce referential integrity even when no relationship decorator is defined.
260
260
  - `Create` and `Update` automatically add DynamoDB condition checks for standalone foreign keys (those without a relationship decorator) to ensure the referenced entity exists, enabling referential integrity even when no denormalised access pattern is required.
261
261
 
@@ -293,16 +293,16 @@ class Course extends MyTable {
293
293
 
294
294
  ### Relationships
295
295
 
296
- Dyna-Record supports defining relationships between entities such as [@HasOne](https://dyna-record.com/functions/HasOne.html), [@HasMany](https://dyna-record.com/functions/HasMany.html), [@BelongsTo](https://dyna-record.com/functions/BelongsTo.html) and [@HasAndBelongsToMany](https://dyna-record.com/functions/HasAndBelongsToMany.html). It does this by de-normalizing records to each of its related entities partitions.
296
+ Dyna-Record supports defining relationships between entities such as [@HasOne](https://docs.dyna-record.com/functions/HasOne.html), [@HasMany](https://docs.dyna-record.com/functions/HasMany.html), [@BelongsTo](https://docs.dyna-record.com/functions/BelongsTo.html) and [@HasAndBelongsToMany](https://docs.dyna-record.com/functions/HasAndBelongsToMany.html). It does this by de-normalizing records to each of its related entities partitions.
297
297
 
298
- A relationship can be defined as nullable or non-nullable. Non-nullable relationships will be enforced via transactions and violations will result in [NullConstraintViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
298
+ A relationship can be defined as nullable or non-nullable. Non-nullable relationships will be enforced via transactions and violations will result in [NullConstraintViolationError](https://docs.dyna-record.com/classes/NullConstraintViolationError.html)
299
299
 
300
- - [@ForeignKeyAttribute](https://dyna-record.com/functions/ForeignKeyAttribute.html) is used to define a foreign key that links to another entity
301
- - Relationship decorators ([@HasOne](#hasone), [@HasMany](#hasmany), [@BelongsTo](https://dyna-record.com/functions/BelongsTo.html), [@HasAndBelongsToMany](#hasandbelongstomany)) define how entities relate to each other.
300
+ - [@ForeignKeyAttribute](https://docs.dyna-record.com/functions/ForeignKeyAttribute.html) is used to define a foreign key that links to another entity
301
+ - Relationship decorators ([@HasOne](#hasone), [@HasMany](#hasmany), [@BelongsTo](https://docs.dyna-record.com/functions/BelongsTo.html), [@HasAndBelongsToMany](#hasandbelongstomany)) define how entities relate to each other.
302
302
 
303
303
  #### HasOne
304
304
 
305
- [Docs](https://dyna-record.com/functions/HasOne.html)
305
+ [Docs](https://docs.dyna-record.com/functions/HasOne.html)
306
306
 
307
307
  ```typescript
308
308
  import {
@@ -337,7 +337,7 @@ class Grade extends MyTable {
337
337
 
338
338
  ### HasMany
339
339
 
340
- [Docs](https://dyna-record.com/functions/HasMany.html)
340
+ [Docs](https://docs.dyna-record.com/functions/HasMany.html)
341
341
 
342
342
  ```typescript
343
343
  import { Entity, NullableForeignKey, BelongsTo, HasMany } from "dyna-record";
@@ -391,9 +391,9 @@ class Course extends MyTable {
391
391
 
392
392
  ### HasAndBelongsToMany
393
393
 
394
- [Docs](https://dyna-record.com/functions/HasAndBelongsToMany.html)
394
+ [Docs](https://docs.dyna-record.com/functions/HasAndBelongsToMany.html)
395
395
 
396
- HasAndBelongsToMany relationships require a [JoinTable](https://dyna-record.com/classes/JoinTable.html) class. This represents a virtual table to support the relationship
396
+ HasAndBelongsToMany relationships require a [JoinTable](https://docs.dyna-record.com/classes/JoinTable.html) class. This represents a virtual table to support the relationship
397
397
 
398
398
  ```typescript
399
399
  import {
@@ -435,9 +435,9 @@ class Student extends OtherTable {
435
435
 
436
436
  ### Create
437
437
 
438
- [Docs](https://dyna-record.com/classes/default.html#create)
438
+ [Docs](https://docs.dyna-record.com/classes/default.html#create)
439
439
 
440
- The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using UUIDs or custom id field if [IdAttribute](<(https://dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
440
+ The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using UUIDs or custom id field if [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
441
441
 
442
442
  To use the create method, call it on the model class you wish to create a new record for. Pass the properties of the new record as an object argument to the method. Only attributes defined on the model can be configured, and will be enforced via types and runtime schema validation.
443
443
 
@@ -482,20 +482,20 @@ const grade: Grade = await Grade.create(
482
482
 
483
483
  #### Error handling
484
484
 
485
- The method is designed to throw errors under various conditions, such as transaction cancellation due to failed conditional checks. For instance, if you attempt to create a `Grade` for an `Assignment` that already has one, the method throws a [TransactionWriteFailedError](https://dyna-record.com/classes/TransactionWriteFailedError.html).
485
+ The method is designed to throw errors under various conditions, such as transaction cancellation due to failed conditional checks. For instance, if you attempt to create a `Grade` for an `Assignment` that already has one, the method throws a [TransactionWriteFailedError](https://docs.dyna-record.com/classes/TransactionWriteFailedError.html).
486
486
 
487
487
  #### Notes
488
488
 
489
- - Automatic Timestamp Management: The [createdAt](https://dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://dyna-record.com/classes/default.html#updatedAt) fields are managed automatically and reflect the time of creation and the last update, respectively.
490
- - Automatic ID Generation: Each entity created gets a unique [id](https://dyna-record.com/classes/default.html#id) generated by the uuidv4 method.
491
- - This can be customized [IdAttribute](<(https://dyna-record.com/functions/IdAttribute.html)>) to support custom id attributes
489
+ - Automatic Timestamp Management: The [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields are managed automatically and reflect the time of creation and the last update, respectively.
490
+ - Automatic ID Generation: Each entity created gets a unique [id](https://docs.dyna-record.com/classes/default.html#id) generated by the uuidv4 method.
491
+ - This can be customized [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) to support custom id attributes
492
492
  - Relationship Management: The ORM manages entity relationships through DynamoDB's single-table design patterns, creating and maintaining the necessary links between related entities.
493
493
  - Conditional Checks: To ensure data integrity, the create method performs various conditional checks, such as verifying the existence of entities that new records relate to.
494
494
  - Error Handling: Errors during the creation process are handled gracefully, with specific errors thrown for different failure scenarios, such as conditional check failures or transaction cancellations.
495
495
 
496
496
  ### FindById
497
497
 
498
- [Docs](https://dyna-record.com/classes/default.html#findById)
498
+ [Docs](https://docs.dyna-record.com/classes/default.html#findById)
499
499
 
500
500
  Retrieve a single record by its primary key.
501
501
 
@@ -529,7 +529,7 @@ const course = await Course.findById("123", {
529
529
 
530
530
  ### Query
531
531
 
532
- [Docs](https://dyna-record.com/classes/default.html#query)
532
+ [Docs](https://docs.dyna-record.com/classes/default.html#query)
533
533
 
534
534
  The query method is a versatile tool for querying data from DynamoDB tables using primary key conditions and various optional filters. This method enables fetching multiple items that match specific criteria, making it ideal for situations where more than one item needs to be retrieved based on attributes of the primary key (partition key and sort key).
535
535
 
@@ -835,7 +835,7 @@ const result = await Customer.query(
835
835
 
836
836
  ### Update
837
837
 
838
- [Docs](https://dyna-record.com/classes/default.html#update)
838
+ [Docs](https://docs.dyna-record.com/classes/default.html#update)
839
839
 
840
840
  The update method enables modifications to existing items in a DynamoDB table. It supports updating simple attributes, handling nullable fields, and managing relationships between entities, including updating and removing foreign keys. Only attributes defined on the model can be updated, and will be enforced via types and runtime schema validation.
841
841
 
@@ -850,7 +850,7 @@ await Customer.update("123", {
850
850
 
851
851
  #### Removing attributes
852
852
 
853
- Note: Attempting to remove a non nullable attribute will result in a [NullConstraintViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
853
+ Note: Attempting to remove a non nullable attribute will result in a [NullConstraintViolationError](https://docs.dyna-record.com/classes/NullConstraintViolationError.html)
854
854
 
855
855
  ```typescript
856
856
  await ContactInformation.update("123", {
@@ -873,7 +873,7 @@ await PaymentMethod.update("123", {
873
873
 
874
874
  Nullable foreign key references can be removed by setting them to null
875
875
 
876
- Note: Attempting to remove a non nullable foreign key will result in a [NullConstraintViolationError](https://dyna-record.com/classes/NullConstraintViolationError.html)
876
+ Note: Attempting to remove a non nullable foreign key will result in a [NullConstraintViolationError](https://docs.dyna-record.com/classes/NullConstraintViolationError.html)
877
877
 
878
878
  ```typescript
879
879
  await Pet.update("123", {
@@ -967,7 +967,7 @@ const updatedInstance = await paymentMethodInstance.update(
967
967
 
968
968
  ### Delete
969
969
 
970
- [Docs](https://dyna-record.com/classes/default.html#delete)
970
+ [Docs](https://docs.dyna-record.com/classes/default.html#delete)
971
971
 
972
972
  The delete method is used to remove an entity from a DynamoDB table, along with handling the deletion of associated items in relationships (like HasMany, HasOne, BelongsTo) to maintain the integrity of the database schema.
973
973
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dyna-record",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Typescript Data Modeler and ORM for Dynamo",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",