v2.3.0
Major Feature Release
This release has compatibility issues. See below.
Features
- Public and improved OneTableError class. #240.
- Separate the Table constructor params and Schema params.
- Add schema field properties "isoDates", client to override the Table defaults.
- Add schema field property "ttl" to support DynamoDB TTL attributes. #233.
- Update schema documentation to 1.1.0.
- Refactor how UUIDs were defined.
- A collection of good fixes.
Compatibility Issues
Updating Items with Unique Attributes
The fix for #245 clarifies the return values for update(). Updates that use transactions (including updating items with unique attributes) will throw an exception if params.return requests a result be returned. DynamoDB does not support returning results from transactions. If no params.return are supplied, the current behavior is preserved and update() returns the client supplied properties but warns to say this will throw an exception in 2.4. Added support for params {return: 'get'} to do a transparent full get request. Normal non-transactional update() path remains the same.
Updating Indexes
The params updateIndexes
has been removed. Previously when this param was false (default), updates to key attributes were silently omitted to prevent creating new items on an update. Due to the attribute-exists checks that update performs, this param is no longer needed. If you specify params.exists: null, then an update may perform a create when changing key attributes. Note this can also happen if you change attributes that are ingredients in key value templates. Note also that there is no default attribute_exists protection when modifying attributes that are used in GSI keys.
Error Class
The OneTableError and OneTableArgError classes are now exported and public. The stack
property while present is now not rendered by the error toString() method.
See #240 for details.
LSIs
Previously when defining LSIs in the schema index section, you could either omit the hash key or set the hash key to that of the primary index. Now, you must include "type": "local"
to request a LSI index.
UUID
The Schema field uuid
property has been renamed generate
and must be set to 'ulid', 'uuid' or true. If true, a custom ID generator must be supplied to the Table constructor. The Table params constructor uuid
is renamed generate
and will now only take a custom ID generator function as a value. The Table.setMakeID is renamed setGenerator. You can use this function as an alternative to providing the generator to the Table constructor. The documentation regarding the UUID is updated to not that it is not fully UUIDv4 compliant and that ULIDs should be used by default.
See #191 for more details.
Table Constructor Parameters
The following table constructor parameters have been removed and moved to the Schema.params.
+ createdField?: string, // Name of "created" timestamp attribute. Default to 'created'.
+ hidden?: boolean, // Hide key attributes in Javascript properties. Default false.
+ isoDates?: boolean, // Set to true to store dates as Javascript ISO Date strings. Default false.
+ nulls?: boolean, // Store nulls in database attributes. Default false.
+ timestamps?: boolean, // Make "created" and "updated" timestamps. Default true.
+ typeField?: string, // Name of model type attribute. Default "_type".
+ updatedField?: string, // Name of "updated" timestamp attribute. Default 'updated'.
Fixes
- Extend wait port timeout for unit tests
- Remove "tunnel" from doc as TypeScript now supports begins etc directly.
- Fix typescript find with empty parameters
- Fix where clauses with newlines in values
- Fix transforming read items with nulls
- Fix partial properties in TypeScript find #232
- Fix #239 using type as hash or sort
- Fix #241 timestamps not created if not specified in schema params.
- Fix #242 with reserved words in create
- Fix #244 where update does not update indexed properties. Removed updateIndexes param.
- Fix #245 return value from update with unique attributes
- BatchWrite will retry unprocessed items with exponential delay (with jitter) if the update fails. Set params.reprocess to false to disable retries.
- Documentation improvements
Thanks
Thanks in particular to @rjmackay, @AndrewCathcart, @kujtimiihoxha, @BDQ, @onhate who raised issues and provided great feedback.