easymongoosedb

0.1.1 • Public • Published

EasyMongooseDB

EasyMongooseDB takes a lot of the make work around quickly setting up a connection to a MongoDB database with Mongoose, as well as providing helpful functions around models and schema creation.

Installation

npm install easymongoosedb

Example Usage

Connection to a database

var easydb = require('easymongoosedb');

var db = easydb({
    url: 'mongodb://127.0.0.1:27017/testdb', // Path to your database
    type: 'single', // Can be set/single
    modelsDir: path.join(__dirname, 'schemas') // Path to the schemas
});

db.connect(function(err) {
    
});

Getting a model

// Async
db.getModel('user', function(err, User) {
    User.find(...);
});

// Get many models
db.getModels(['user', 'invoices'], function(err, User, Invoices) {
    
});

// Sync
var User = db.getModelSync('User');

Namespacing

EasyMongooseDB provides the ability to created use a single schema to create many namespaced models (useful for creating instanced collections).

TODO - Add details

License

EasyMongooseDB is distributed under an MIT License_

Readme

Keywords

none

Package Sidebar

Install

npm i easymongoosedb

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • nathanoehlman