1.1.4 • Published 4 years ago

mongodbconnection-wrapper v1.1.4

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

model def

var BaseModel = require('mongodbconnection-wrapper').getBaseModel();

class VotingModel extends BaseModel {

    constructor(dbMgr, options){
        super(dbMgr, options);
        this.idName = "v"
        this.modelName = 'votings';
    }

}

module.exports = VotingModel;

schema def

'use strict';

function loadSchema(Schema,db){

    var voting = {
        "_id":{
            type:String,
            trim:true
        },
        "userId" :{
            "type": String,
            "required": true
        },
        "cOn" : {
            type : Date,
            default: Date.now
        },
        "mOn" : {
            type : Date,
            default: Date.now
        }
    };

    db.model('votings', new Schema(voting), 'votings');
}
module.exports = loadSchema;

initializing

var dbMgr = require('mongodbconnection-wrapper');

function initiateDataBase(callback) {
    var dbname = process.env.NODE_ENV === 'test' ? "test" : undefined;
    debug("initiating database");
    var modelsInst = dbMgr.getModel();
    return dbMgr.initialize(config.get("db"),{dbName: dbname, modelPath: "./db/models", schemaPath:"./db/schemas"})
    .then(function(dbMgr){
        return callback && callback(dbMgr);
    });
}


initiateDataBase();
1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.2

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

5 years ago