Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1602/orm
simple object redis mapper
https://github.com/1602/orm
Last synced: about 1 month ago
JSON representation
simple object redis mapper
- Host: GitHub
- URL: https://github.com/1602/orm
- Owner: 1602
- Created: 2010-11-02T18:00:05.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2010-12-22T06:34:52.000Z (almost 14 years ago)
- Last Synced: 2024-04-15T07:19:12.514Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 148 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
About
=====ORM is simple Object-redis-mapper, which provides simple object interface to redis data storage.
It adds some methods to the selected model: create, find, exists, etc..Check out test to learn how to use this lib.
Prerequisites
=============1. Redis server version 2.0.3
2. node version 0.2.2
3. nodeunit (for running tests)Installation
============Install usin NPM
npm install node-redis-mapper
Or from sources on github
mkdir vendor
git clone git://github.com/1602/orm.git vendor/ormUsage
=====var m = require('node-redis-mapper').apply_to_models(__dirname + '/app/models/');
or
// load models namespace
var models = require('./lib/your_models');
// or define model
var models = {
User: function User() {
User.attributes = {
name: 'string',
email: 'string',
birthdate: 'datetime'
};
}
};// add persistence
require('node-redis-mapper').mix_persistence_methods(models);models.User.create(function () {
var user = this;
console.log(user.created_at);
user.name = 'John Doe';
user.email = '[email protected]';
user.save(function (err) {
if (!err) {
console.log('User saved');
} else {
console.log('Could not save user');
}
});
});models.User.connection.select(10);
Test
====# please note, tests by default running on database 9
nodeunit test/orm.jsContributing
============Contributions to the project are most welcome, so feel free to fork and improve. When submitting a pull request, please ensure that JSLint coding style is met.