0.0.3 • Published 7 years ago
node-dynamodb v0.0.3
node-dynamodb
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 environmentdatabase
- The environmentconnection
- Object with an instance ofnew AWS.DynamoDB
fordb
andnew AWS.DynamoDB.DocumentClient
forclient
logger
- Optional interface that implementsinfo
,warn
,error
,fatal
,debug
,trace
andchild
.
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
- Contact: hi@danamajid.com
Twitter: http://twitter.com/dnmjd
Credits
Shout out to Nathan Peck for sharing his exploration project