0.0.5 • Published 8 years ago

load-model v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

load-model

Load model Mongoose NPM version

Example of creating models

module.exports = function(mongoose){
    var Schema = mongoose.Schema;
    var Model = Schema({
        name:String
    },{collection:'collection_name'});
    return mongoose.model('model_name',Model);
}

or

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Model = Schema({
        name:String
},{collection:'collection_name'});
module.exports = mongoose.model('model_name',Model);

Example usage

var mongoose = require('mongoose');
var load = require('./load-model');
var Models = load(__dirname+'/models/',mongoose);//or load('./models/',mongoose) and load('../models/',mongoose)
Models.jobs.find({},function(e,jobs){});

or

var Models = load(__dirname+'/models/');
Models.jobs.find({},function(e,jobs){});

the name of the sample template is "jobs" is the naming of the file corresponding to "./models/jobs.js"

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago