active_record

Rails ActiveRecord inspired for Nodejs.

npm install active_record
10 downloads in the last week
16 downloads in the last month

ActiveRecord Nodejs

Simplify yours queries, transactions, relations, etc. Compatible with: (mysql, postgresql, sqlite3)

VERSION

0.0.3

Synopsis

Configure Connection:

    var ActiveRecord = require('active_record').Base;

    ActiveRecord.configure_connection({
        driver: 'mysql',
        user: 'root',
        password: '',
        port: 3306,
        hostname: 'localhost',
        database: 'chat',
        pool: true
    })

    ActiveRecord.establish_connection()

Create a model:

    var ActiveRecord = require('active_record')
        ,    inherits = require('util').inherits

    module.exports = Model

    inherits(Model, ActiveRecord)
    function Model (options){
        this.id = options.id
        this.name = options.name
        this.password = options.password
    }

    Model.super_() // Class methods

Usage


    for( i in [1,2,3])
        Model.create({ name: 'Foo', password: 'Bar' }, function(data){ ... })

    Model.destroy(1, function(data){ ... })
    Model.update(2, {name: 'Bar', password: 'Foo'}, function(data){ ... })


    Model.find([1,2,3], function(data){ ... })
    Model.find_by_name('Bar', function(data){ ... })

API

See the API documentation in the wiki.

License

GPLv3

npm loves you