Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jupiterone/dynamodb-dao

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jupiterone/dynamodb-dao - npm Package Compare versions

Comparing version 1.4.0 to 1.5.2

28

index.d.ts

@@ -83,5 +83,17 @@ import { DocumentClient } from 'aws-sdk/clients/dynamodb';

}
export declare type PutOptions = ConditionalOptions;
export declare type UpdateOptions = ConditionalOptions;
export declare type DeleteOptions = ConditionalOptions;
export interface SaveBehavior {
optimisticLockVersionAttribute?: string;
optimisticLockVersionIncrement?: number;
}
export interface MutateBehavior {
ignoreOptimisticLocking?: boolean;
}
export declare type PutOptions = ConditionalOptions & MutateBehavior;
export declare type UpdateOptions = ConditionalOptions & MutateBehavior;
export declare type DeleteOptions = ConditionalOptions & MutateBehavior;
export interface BuildOptimisticLockOptionsInput extends ConditionalOptions {
versionAttribute: string;
versionAttributeValue: any;
}
export declare function buildOptimisticLockOptions(options: BuildOptimisticLockOptionsInput): ConditionalOptions;
export interface GenerateUpdateParamsInput extends UpdateOptions {

@@ -92,6 +104,7 @@ tableName: string;

}
export declare function generateUpdateParams(options: GenerateUpdateParamsInput): DocumentClient.UpdateItemInput;
interface DynamoDbDaoInput {
export declare function generateUpdateParams(options: GenerateUpdateParamsInput & SaveBehavior): DocumentClient.UpdateItemInput;
export interface DynamoDbDaoInput<T> {
tableName: string;
documentClient: DocumentClient;
optimisticLockingAttribute?: keyof NumberPropertiesInType<T>;
}

@@ -118,3 +131,4 @@ export declare function encodeQueryUntilLimitCursor(lastKey: string | undefined, skip: number | undefined): string;

readonly documentClient: DocumentClient;
constructor(options: DynamoDbDaoInput);
readonly optimisticLockingAttribute?: keyof NumberPropertiesInType<DataModel>;
constructor(options: DynamoDbDaoInput<DataModel>);
/**

@@ -128,3 +142,3 @@ * Fetches an item by it's key schema

*/
delete(key: KeySchema, options?: DeleteOptions): Promise<DataModel | undefined>;
delete(key: KeySchema, options?: DeleteOptions, data?: Partial<DataModel>): Promise<DataModel | undefined>;
/**

@@ -131,0 +145,0 @@ * Creates/Updates an item in the table

{
"name": "@jupiterone/dynamodb-dao",
"version": "1.4.0",
"version": "1.5.2",
"description": "DynamoDB Data Access Object (DAO) helper library",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -140,2 +140,39 @@ # dynamodb-dao

**Optimistic Locking with Version Numbers**
For callers who wish to enable an optimistic locking strategy there are two
available toggles:
1. Provide the attribute you wish to be used to store the version number. This
will enable optimistic locking on the following operations: `put`, `update`,
and `delete`.
Writes for documents that do not have a version number attribute will
initialize the version number to 1. All subsequent writes will need to
provide the current version number. If an out-of-date version number is
supplied, an error will be thrown.
Example of Dao constructed with optimistic locking enabled.
```
const dao = new DynamoDbDao<DataModel, KeySchema>({
tableName,
documentClient,
optimisticLockingAttribute: 'version',
});
```
2. If you wish to ignore optimistic locking for a save operation, specify
`ignoreOptimisticLocking: true` in the options on your `put`, `update`, or
`delete`.
NOTE: Optimistic locking is NOT supported for `batchWrite` or `batchPut`
operations. Consuming those APIs for data models that do have optimistic locking
enabled may clobber your version data and could produce undesirable effects for
other callers.
This was modeled after the
[Java Dynamo client](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptimisticLocking.html)
implementation.
## Developing

@@ -142,0 +179,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc