mongoose.helper

API for mongoose scheme

npm install mongoose.helper
2 downloads in the last week
4 downloads in the last month

mongoose.helper

Simple mongoose models api Created by Mikelis Asnins E-mail: mikelis.asnins@yahoo.com

Developed for commercial mass e-mail sending application (not spammer :D, application is usded for sending reminders, invoices, etc.)

addSchema('name', MongooseSchema) -> adds mongoose schema to list, for later use

create(Schema or 'name', {data}, callback) -> create record in db

//validateAndCreate -> validate data and create record (WIP)

list(Schema or 'name', callback) -> list all data

remove(Schema or 'name', callback) -> remove data

find(Schema or 'name', {filter}, callback) -> find record

findByID(Schema or 'name', id, callback) -> find record by id

findOne(Schema or 'name', filter, callback) -> return one record

paginate(Schema or 'name', pageSize, pageNumber, callback) -> simple mongoDB paginator. pageSize --> record count in one page, pageNumber --> current page number

count(Schema or 'name', filter, callback) -> return record count

exists(Schema or 'name', filter, callback) -> return true if record exists

more features comming soon!

example:

var api = require('mongoose.helper');
api.addSchema('tasks', require('../models/task'));
api.addSchema('spools', require('../models/spools'));

api.create('tasks', {
                    name: 'test',
                    created_by: 'Mikelis'
                    }, function (err, doc) {
                        if (!err) {
                            console.log('success');
                        } else {
                            console.log(err);
                        }
                    });

api.list('spools', {
                    name: 'test',
                    created_by: 'Mikelis'
                    }, function(err, doc){
                        if (!err) {
                            console.log(doc);
                        } else {
                            console.log(err);
                        }
                    });
npm loves you