# 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>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shiftcode.gitbook.io/dynamo-easy/get-started/jump-into-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
