Skip to content

easily store and find javascript objects in redis from node.js

Notifications You must be signed in to change notification settings

thomas-silva/redis-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

##redis-mapper

Create models, save objects, and find them later.

This project currently only works with objects one layer deep utilizing strings. Other primitives will be added along with sub objects and arrays.

##Start

var mapper = require('redis-mapper');
var db = mapper(6379, '127.0.0.1');

##Model

CustomerModel = db.modelFactory('Customer',
    {
        first_name: String,
        last_name:  String
    }
);

##Save

var thomas = {
    first_name: 'thomas',
    last_name:  'silva'
};

CustomerModel.save(thomas, function(error, id) {

    if (error)
        return console.log(error);

    console.log('new customer id', id);
});

##Find

CustomerModel.find({first_name: 'thomas'}, function(error, results) {

    if (error)
        return console.log(error);

    console.log(JSON.stringify(results));
});

About

easily store and find javascript objects in redis from node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published