Builders

A DynamoDB expression builder that simplifies generating update items requests by composing small functions. Functions from this module can be imported from the @flybondi/flynamo/builders namespace. You can feed the result of updateExpression to the payload argument of update or updateFor.

Source:
See:
Example
const { updateExpression, put } = require('@flybondi/flynamo/builders');

 const expression = updateExpression('SET',
   compose(
     put('availableSeats', 42),
     put('pnr', '2LWJRW'),
   )
 );

 await update(42, expression, { TableName: 'SomeTable' });

Methods

(static) append(Attribute, Value) → {function}

Source:
See:

Returns a function that creates the mandatory UpdateExpression, AttributeNames and AttributeValues needed to build an append operation and merges everything with the given object containing UpdateExpression, AttributeNames and AttributeValues keys.

Parameters:
Name Type Description
Attribute String

array that you want to extend

Value Array

to add at the end of the array

Returns:

Expects an Object to merge the new UpdateExpression, AttributeNames and AttributeValues generated.

Type
function

(static) put(attribute, value) → {function}

Source:
See:

Returns a function that creates the mandatory UpdateExpression, AttributeNames and AttributeValues needed to build a put operation and merges everything with the given object containing UpdateExpression, AttributeNames and AttributeValues keys.

Parameters:
Name Type Description
attribute String

name that you want to set

value Array

of the attribute

Returns:

that expects an Object to merge the new UpdateExpression, AttributeNames and AttributeValues generated.

Type
function

(static) remove(attribute) → {function}

Source:
See:

Returns a function that creates the mandatory UpdateExpression, AttributeNames and AttributeValues needed to build a REMOVE operation and merges everything with the given object containing UpdateExpression, AttributeNames and AttributeValues keys.

Parameters:
Name Type Description
attribute String

Attribute to be removed.

Returns:

Expects an Object to merge with the new UpdateExpression, AttributeNames and AttributeValues generated.

Type
function

(static) updateExpression(Action, Operations) → {function}

Source:
See:

Returns a function that, when invoked with a set of default values for a dynamo expression, it creates the mandatory UpdateExpression, AttributeNames and AttributeValues needed to build the action operations created by the given operation function.

Parameters:
Name Type Description
Action String

to execute in DynamoDB, it can be SET, ADD, DELETE or REMOVE.

Operations function

that returns an object with the operations to execute and their parameters.

Returns:

Expects an Object to merge the new UpdateExpression, AttributeNames and AttributeValues generated.

Type
function