/**auother : zhz
* mongodb : count函数 ,统计条数
* selecter: 筛选条件
* */
HelperMongo.prototype.mGcount = function(collectionName,selecter,callback) {
var self = this;
var reqId = _reqId++;
_log(reqId,"开始查找数量... "+collectionName+","+JSON.stringify(selecter));
function process(callback) {
_getCollection(self, collectionName, function (collection) {
collection.count(selecter,function(error,rst){
if (error) {
global.err(collectionName + " : " + JSON.stringify(error));
return;
}
_log(reqId, "查找成功--> " + JSON.stringify(rst));
if(callback != undefined) callback(rst);
});
});
}
return _judgePromise(process,callback);
};
function _judgePromise(process,callback){
if(callback==undefined){
return new global.Promise(function(resolve, reject) {
process(resolve);
});
}else{
process(callback);
}
}