Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

danamajid/node-dynamodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-dynamodb CircleCI

A (work-in-progress) Mongoose-like API for DynamoDB

DynamoDB

Example:

var DynamoDB = require('node-dynamodb');

Methods

DynamoDB.model(schema, options)

Define your model.

Example:

var Movie = DynamoDB.model('Movies', new DynamoDB.Schema({
  year: {
    type: DynamoDB.types.Number,
    index: DynamoDB.types.Hash
  },
  title: {
    type: DynamoDB.types.String,
    index: DynamoDB.types.Range
  }
}, {
  readCapacity: 10,
  writeCapacity: 20
}));

DynamoDB.connect(options, callback);

Connect, and sync your defined models.

  • env - The environment
  • database - The environment
  • connection - Object with an instance of new AWS.DynamoDB for db and new AWS.DynamoDB.DocumentClient for client
  • logger - Optional interface that implements info, warn, error, fatal, debug, trace and child.

Example:

DynamoDB.connect({
  env: 'dev',
  database: 'biem',
  connection: {
    db: new AWS.DynamoDB({
      endpoint: new AWS.Endpoint('http://localhost:4337')
    }),
    client: new AWS.DynamoDB.DocumentClient({
      endpoint: new AWS.Endpoint('http://localhost:4337')
    })
  }
}, function(err, data) {
  console.log(data);
  /*
  {
    sync: {
      none: [],
      created: ['Movies'],
      updated: []
    }
  }
  */
});

Movie.put(details, callback);

Put an item.

Example:

Movie.put({
  year: 2001,
  title: 'A Beautiful Mind'
}, done);

Movie.get(details, callback);

GET an item.

Example:

Movie.get({
  year: 2001,
  title: 'A Beautiful Mind'
}, done);

Author

Credits

Shout out to Nathan Peck for sharing his exploration project

About

Node.js Mongoose-like API for DynamoDB (WIP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published