A (work-in-progress) Mongoose-like API for DynamoDB
Example:
var DynamoDB = require('node-dynamodb');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
}));Connect, and sync your defined models.
env- The environmentdatabase- The environmentconnection- Object with an instance ofnew AWS.DynamoDBfordbandnew AWS.DynamoDB.DocumentClientforclientlogger- Optional interface that implementsinfo,warn,error,fatal,debug,traceandchild.
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: []
}
}
*/
});Put an item.
Example:
Movie.put({
year: 2001,
title: 'A Beautiful Mind'
}, done);GET an item.
Example:
Movie.get({
year: 2001,
title: 'A Beautiful Mind'
}, done);- Contact: hi@danamajid.com
- Twitter: http://twitter.com/dnmjd
Shout out to Nathan Peck for sharing his exploration project