1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * Created by benzhan on 15/8/13.
- */
- var prototype = Model.prototype;
- var MySql = require('../framework/lib/oujMySql.js');
- var TableHelper = require('../framework/lib/TableHelper.js');
- function Model(tableName, dbKey) {
- this.tableName = tableName;
- this.dbKey = dbKey || 'default';
- if (!tableName) {
- return;
- }
- /**
- * 数据库的表助手
- * @type {TableHelper}
- */
- this.objTable = new TableHelper(tableName, this.dbKey);
- /**
- * 数据库的操作类
- * @type {oujMySql}
- */
- this.objDb = new MySql(this.dbKey);
- }
- /**
- * 返回数据库操作对象
- * @param dbKey
- * @returns {oujMySql}
- */
- prototype.getObjDb = function(dbKey) {
- if (dbKey) {
- return new MySql(dbKey);
- } else {
- return this.objDb;
- }
- }
- module.exports = Model;
|