app/models/AppModel.js
/**
 * Main Model all models extends this one
 */
Main Model all models extends this one
Main Model all models extends this one
function AppModel () {
	var scope = this;
	var url = process.env.MONGO_URL;
	var db = null;
	this.table = 'calidadaire';
	this.collection = {};
	this.connect = function(cb) {
		MongoClient.connect(url, function(err, db) {
			assert.equal(null, err);
			scope.db = db;
			scope.collection = db.collection(scope.table);
		});
	};
	this.close = function(){
		db.close();
	};
}
function AppModel ( ) { var scope = this ; var url = process . env . MONGO_URL ; var db = null ; this . table = 'calidadaire' ; this . collection = { } ; this . connect = function ( cb ) { MongoClient . connect ( url , function ( err , db ) { assert . equal ( null , err ) ; scope . db = db ; scope . collection = db . collection ( scope . table ) ; } ) ; } ; this . close = function ( ) { db . close ( ) ; } ; }
Main Model all models extends this one
Main Model all models extends this one
/**
	 * keep scope clean
	 * @type {AppModel}
	 */ /**
	 * string
	 * @type {String}
	 */ /**
	 * mongodb reference
	 * @type {Object}
	 */ /**
	 * collection name
	 * @type {String}
	 */ /**
	 * mongo collection
	 * @type {Object}
	 */ /**
	 * connect to mongo server and return the collection
	 * @param  {Function} cb callback
	 * @return {collection}
	 */ /**
	 * close connection to the database
	 * @return {void}
	 */