This Person model will be used with the table name persons.
The table name is built with ${kebabCase(modelName)}s - unless you provide one with @Model({tablename: 'yourCustomTableName').
then create a DynamoStore instance to execute actions against the DynamoDB.
app.ts
import { DynamoStore } from'@shiftcoders/dynamo-easy'import*as AWS from'aws-sdk/global'import { Person } from'./models'// update the aws config with your credentials to enable successful connectionAWS.config.update({ region:'yourAwsRegion' })constpersonStore=newDynamoStore(Person)// add a new itempersonStore.put({ id:'wernerv', name:'Werner Hans Peter Vogels', yearOfBirth:1958 }).exec().then(() => {console.log('person stored') })// search for a single person by known idpersonStore.query().wherePartitionKey('wernerv').execSingle().then(person => {console.log('got person', person) })// returns all persons where the name starts with wpersonStore.scan().whereAttribute('name').beginsWith('w').exec().then((persons:Person[]) => {console.log('all persons', persons) })
We created a demo project to receive a good impression how dynamo-easy can be used. See Link below.