You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 19, 2023. It is now read-only.
Using the documentation of both this repository (in the Operations with Expressions section) and dynamodb-expression, I believe there is a specific issue with using conditions on put query.
(a) the documentation of this repo is missing a parenthesis (possibly un-needed UpdateExpression as well)
(b) the follow populates a putItem query successfully over and over
Model:
@table('tests')
class Test {
@hashKey()
id?: string;
@rangeKey()
name?: string;
}
Action:
import {
FunctionExpression,
AttributePath,
UpdateExpression
} from '@aws/dynamodb-expressions';
import { v4 as uuidv4 } from 'uuid';
function createData() {
const obj = Object.assign(new Test, {
id: uuidv4(),
name: 'same name'
})
const condition = new FunctionExpression('attribute_not_exists', new AttributePath('name'));
return mapper.put(obj, { condition: condition })
}
createData() // should work with no existing record
createData() // should throw error as name attribute already exists, but does not throw error
(c) all tests cases for FunctionExpression (at least in packages/dynamodb-expressions/src/FunctionExpression.spec.ts) appear to be Red Herrings, not actually testing if a expression works past weather it will accept parameters
(d) there also appear to be no put tests in packages/dynamodb-data-mapper/src/DataMapper.spec.ts only available for delete & query methods