Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Node.js document mapper for DynamoDB
JavaScript

This branch is 228 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
test
.gitignore
.jshintrc
.travis.yml
README.md
index.js
package.json

README.md

mambo

Little wrapper for dynamo models

Build Status

Install

 npm install mambo

Testing

git clone
npm install
npm test

Example

var mambo = require('mambo'),
    Schema = mambo.Schema,
    StringField = mambo.StringField,
    NumberField = mambo.NumberField,
    JSONField = mambo.JSONField,
    DateField = mambo.DateField;

var Comment = new mambo.Model(new Schema(
        'Comments', ['post_id', 'created'],
        {
            'post_id': NumberField,
            'created': DateField,
            'comment': StringField,
            'author': StringField,
            'liked_by': JSONField
        }
    ), new Schema('Users', 'username', {
        'username': StringField,
        'name': StringField,
        'lastCommentPosted': DateField
    })
);

Comment.getAll = function(postId){
    this.objects('comments', postId)
        .limit(5)
        .fetch().then(function(comments){
            console.log('Comments for post ' + postId + ':\n'); console.log(JSON.stringify(comments, null, 4));
        });
};

Comment.post = function(postId, author, comment){
    this.insert('comments',
        {
            'post_id': postId,
            'created': new Date(),
            'author': author,
            'comment': comment,
            'liked_by': []
        })
        .commit().then(function(){
        console.log('Comment added!');
    });
};

module.exports = Comment;
Something went wrong with that request. Please try again.