问题描述
- node.js bearcat-dao 使用是domainSupport 总是 null
-
var Demo = require('../bean/Demo');var DemoDao = function() {
// this.$id="demoDao";
// this.$init = "init";
this.domainDaoSupport = null;
}DemoDao.prototype.setDomainDaoSupport = function(domainDaoSupport) {
this.domainDaoSupport = domainDaoSupport;
}DemoDao.prototype.getDomainDaoSupport = function() {
return this.domainDaoSupport;
}DemoDao.prototype.init = function() {
this.domainDaoSupport.initConfig(Demo);
}
DemoDao.prototype.transaction = function(txStatus){
this.domainDaoSupport.transaction(txStatus);
return this;
}DemoDao.prototype.getList = function(params,cb){
var sql = ' 1=1 limit ?,? ';
return this.domainDaoSupport.getListByWhere(sql,params,null,cb);
}module.exports = { //#1
id:"demoDao",
func:DemoDao,
props:[{
name:"domainDaoSupport",
ref:"domainDaoSupport"
}],
"init" : "init"
}
//module.exports = DemoDao;先不看注释的。
问题:
1. service 中如何 使用demoDao (如何装配)。
2. 请教下 #2 位置 的 作用(是将这些信息注入到bearcat中么?)。
3. domainSupport 总是null4. 我总是觉得是我调用 的不对 所以没有将 这个dao 用bearcat 装配进来 。
主要问题可能还是 service 调用 的不对。
下面是官方例子中 装配的方法
module.exports = {
id: "todoService",
func: TodoService,
props: [{
name: "todoDao",
ref: "todoDao"
}]
}
以这种方式 添加到module 时我应该如何 require 呢最近才学习的nodejs 好多不会的
麻烦 各位帮帮忙啦。
谢谢
解决方案
http://www.open-open.com/lib/view/open1425277196118.html