brettlangdon/papernode — pull request #37 by brettlangdon (2012-08-20 23:51:03+00:00)
Title: Db prototype

Remedies #9.

This adds a `papernode.model` object which is a `Schema` object from 1602/jugglingdb.

To add a new model use the following as a base:
```
var model = require('papernode').model;

var NewModel = model.define('NewModel, {
//definition here, as defined by jugglingdb
//https://github.com/1602/jugglingdb/#usage
});

//any inheritance here
var User = model.get('User');
User.hasMany(NewModel, {as: 'models', foreignKey: 'newmodelId'});

module.exports = NewModel;
```

Save this file either in:
* `papernode/lib/model/newmodel.js`
* `papernode/lib/model/NewModel.js`
* `project/dir/models/NewModel.js`
* `project/dir/models/newmodel.js`
* `node_modules/NewModel/index.js`

Retrieve models:

```
var model = require('papernode').model;

var NewModel = model.get('NewModel');

//now use it
```