<commit_before>master|develop
---|---
[![Build Status](https://travis-ci.org/sdawood/dynamo-update-expression.svg?branch=master)](https://travis-ci.org/sdawood/dynamo-update-expression)|[![Build Status](https://travis-ci.org/sdawood/dynamo-update-expression.svg?branch=develop)](https://travis-ci.org/sdawood/dynamo-update-expression)

# dynamo-update-expression


Generate DynamoDB Update Expression by diff-ing original and updated documents.

Allows for generating update expression with no-orphan (create new nodes as you go) or deep paths (ideal for *predefined* document structure), more on that in the examples below.

Optionally include a condition expression with you update to utilize [Optimistic Locking With Version Number](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptimisticLocking.html)


```js
const due = require('./dynamo-update-expression');

due.getUpdateExpression({original, modified, ...options});

due.getVersionedUpdateExpression({original, modified, versionPath: '$.path.to.version', condition: '='});

due.getVersionLockExpression({newVersion: expiryTimeStamp, condition: '<'});

// Bonus!

const {ADD, DELETE, SET} = diff(original, modified /* orphans = false*/);
```

See the options available below:

## Installation

  ```sh
  npm install dynamo-update-expression --save
  ```
<commit_msg>docs(README.md): typos<commit_after>master|develop
---|---
[![Build Status](https://travis-ci.org/sdawood/dynamo-update-expression.svg?branch=master)](https://travis-ci.org/sdawood/dynamo-update-expression)|[![Build Status](https://travis-ci.org/sdawood/dynamo-update-expression.svg?branch=develop)](https://travis-ci.org/sdawood/dynamo-update-expression)

# dynamo-update-expression


Generate DynamoDB Update Expression by diff-ing original and updated documents.

Allows for generating update expression with no-orphan (create new nodes as you go) or deep paths (ideal for *predefined* document structure), more on that in the examples below.

Optionally include a condition expression with your update to utilize [Optimistic Locking With Version Number](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptimisticLocking.html)


```js
const due = require('./dynamo-update-expression');

due.getUpdateExpression({original, modified, ...options});

due.getVersionedUpdateExpression({original, modified, versionPath: '$.path.to.version', condition: '='});

due.getVersionLockExpression({newVersion: expiryTimeStamp, condition: '<'});

// Bonus!

const {ADD, DELETE, SET} = diff(original, modified /* orphans = false*/);
```

See the options available below:

## Installation

  ```sh
  npm install dynamo-update-expression --save
  ```

{'fraction_non_alphanumeric': 0.14170337738619676, 'fraction_numerical': 0.0, 'mean_word_length': 5.630170316301703, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7496933', 'n_tokens_mistral': 833, 'n_tokens_neox': 816, 'n_words': 187}