0.11.1 • Published 11 years ago

lian v0.11.1

Weekly downloads
65
License
-
Repository
github
Last release
11 years ago

Lian

Simple object persistence for node.js with MongoDB.

var lian = require('lian')('localhost/mydb');

function Person (name) {
    lian(this, 'person');
    this.name = name;
}

Person.prototype.getGender = function () {
    return this.gender;
}

var john = new Person('John Smith');
john.gender = "male";

john.save();

Create a projection of Person to find the instance saved above.

var john = new Person('John Smith');
john.find().then(function (results) {

    john = results[0];
    john.name; // "John Smith"
    john.getGender(); // "male"
});

Make some changes to persist.

john.name = "John Anthony Smith";
john.save();

Decoupled, lian's Store object can be used directly.

var Store = require('lian').Store,
    lian  = require('lian');

function Person (name) {
    lian(this, 'person');
    this.name = name;
}

var steve = new Person('steve');

typeof steve.insert // "undefined"

var store = new Store('localhost/mydb');
store.insert(steve);

Goals

  • Avoid writing result to object mapping code over and over.
  • Instance based connections, multiple connections within the same process.
  • All asynchronous operations should return a promise.
  • Store provides an in-memory alternative, for testing.

Development Build Status

Lian uses monk to talk to MongoDB and promised-io for futures.

Clone the repo...

git clone git://github.com/richardhodgson/lian.git

Use npm to install dependencies.

cd lian && \
npm install --dev

Run the tests.

make test

The tests mock out monk, there are integration tests expecting a MongoDB instance running on localhost:27017. They will create a lian-integration database.

make integration-test
0.11.1

11 years ago

0.11.0

11 years ago

0.10.2

11 years ago

0.10.1

11 years ago

0.10.0

11 years ago

0.9.0

11 years ago

0.8.0

11 years ago

0.7.0

11 years ago

0.6.0

11 years ago

0.5.0

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

12 years ago