1.2.27 • Published 6 years ago

daymon v1.2.27

Weekly downloads
4
License
ISC
Repository
-
Last release
6 years ago

** This is in early development so new versions will continuously be published.

*** Usage

var options = {
  convertEmptyStringToNull: true,
  timeStamps: {
    update: 'dateUpdated',
    create: 'dateCreated'
  },
  awsConfig: {
    region: 'aws region'
    accessKeyId: 'aws id',
    secretAccessKey: 'aws secret',
    dynamodb: {
      endpoint: 'some endpoint'
    }
  }
}
var daymon = require('daymon')(options);

var tableName = 'users'
var Model = daymon(tableName);

The awsConfig property on the options object is required. The convertEmptyStringToNull converts empty strings to null values, as dynamodb does not accept empty strings as values. convertEmptyStringToNull is false by default and instead of converting empty strings to null, the property will not be updated.

To automatically set timestamps when calling save() or update(), set timeStamps.create and/or timeStamps.update. The values will be Date.now(). If these keys are set on individual saves or updates before calling save() or update(), the automatic timestamp will not override these values.

*** Query

Model.query(options) => promise;

The options object has the be an object that has a key of either primary index hash key or a secondary index hash key. Error will be thrown otherwise.

You can either pass single value or an array of values:

var queryOptions = {
  id: 'some id'
}

or

var queryOptions = {
  id: ['id1', 'id2', 'id3']
}

*** Scan

Model.scan(options) => promise;

The options object has to be an object. Keys and values can be anything.

*** instance.save();

new Model(objectToSave).save() => promise;

If the objectToSave has no primary index hash key, a unique one will be generated as a String. This will most probably change at some point.

If the objectToSave already has a primary index hash key, an update will be performed instead.

*** instance.update()

new Model(objectWithHashKey).update() => promise

Updates an existing object. It uses dynamodb.documentClient.update and will create a new item if it is not already there.

1.2.27

6 years ago

1.2.26

6 years ago

1.2.25

7 years ago

1.2.24

7 years ago

1.2.23

7 years ago

1.2.22

7 years ago

1.2.21

7 years ago

1.2.20

7 years ago

1.2.19

7 years ago

1.2.18

7 years ago

1.2.17

7 years ago

1.2.16

7 years ago

1.2.15

7 years ago

1.2.14

7 years ago

1.2.13

7 years ago

1.2.12

7 years ago

1.2.11

7 years ago

1.2.10

7 years ago

1.2.9

8 years ago

1.2.8

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago