> For the complete documentation index, see [llms.txt](https://shiftcode.gitbook.io/dynamo-easy/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shiftcode.gitbook.io/dynamo-easy/get-started/jump-into-code.md).

# Jump into code

Start defining your first model by adding at least a `@Model()` decorater and define one property as `@PartitionKey()`

{% code title="person.model.ts" %}

```typescript
import { Model, PartitionKey } from '@shiftcoders/dynamo-easy'

@Model()
export class Person {
  @PartitionKey()
  id: string
  name: string
  age: number
}
```

{% endcode %}

> 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.

{% code title="app.ts" %}

```typescript
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 connection
AWS.config.update({ region: 'yourAwsRegion' })

const personStore = new DynamoStore(Person)

// add a new item
personStore.put({ id: 'wernerv', name: 'Werner Hans Peter Vogels', yearOfBirth: 1958 })
  .exec()
  .then(() => {
    console.log('person stored')
  })

// search for a single person by known id
personStore.query()
  .wherePartitionKey('wernerv')
  .execSingle()
  .then(person => {
    console.log('got person', person)
  })

// returns all persons where the name starts with w
personStore.scan()
  .whereAttribute('name').beginsWith('w')
  .exec()
  .then((persons: Person[]) => {
    console.log('all persons', persons)
  })
```

{% endcode %}

{% hint style="success" %}
We created a demo project to receive a good impression how dynamo-easy can be used. See Link below.
{% endhint %}

{% embed url="<https://github.com/shiftcode/dynamo-easy-demo>" %}

### dynamo-easy demo running in stackblitz

{% embed url="<https://stackblitz.com/edit/dynamo-easy-node-sample>" %}
