Skip to content

Frapwings/fendjs-model-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fendjs-model-mongo

Build Status Coverage Status NPM version Dependency Status

MongoDB model plugin for Fend.js

Installing

$ npm install fendjs-model-mongo

Usage

var Modeler = require('fendjs-model');
var Mongorable = require('fendjs-model-mongo');

Mongorable.connect({
  database: 'test',
  host: 'localhost',
  port: 27017
}, function (err) {
  Modeler.use(Mongorable());
  var Pet = Modeler('Pet')
    .attr('id')
    .attr('name');

  var pet = new Pet({ name: 'Tobi', species: 'Ferret' });
  pet.save(function (err, res) {
    if (err) {
      // Error something todo ...
      return;
    }
    // Something todo ...

    Mongorable.disconnect(function (err) {
      // ...
    });
  });
});

API

Mongorable()

Extend mongorable model plugin constructor.

Mongorable.connect(options, fn)

Connect mongodb.

Mongorable.disconnect(fn)

Disconnect mongodb.

Testing

$ npm install
$ make test

License

MIT license.

See the LICENSE.

Bitdeli Badge