|
@@ -75,20 +75,22 @@ rationItemDAO.prototype.removeRationItems = function(rIds,callback){
|
|
|
};
|
|
|
|
|
|
rationItemDAO.prototype.getRationItemsByCode = function(repId, code,callback){
|
|
|
- rationItemModel.find({"rationRepId": repId, "code": /code/, "$or": [{"isDeleted": null}, {"isDeleted": false}]},function(err,data){
|
|
|
+ rationItemModel.find({"rationRepId": repId, "code": {'$regex': code}, "$or": [{"isDeleted": null}, {"isDeleted": false}]},function(err,data){
|
|
|
if(err) callback(true, "Fail to get items", "")
|
|
|
else callback(false,"Get items successfully", data);
|
|
|
})
|
|
|
};
|
|
|
|
|
|
rationItemDAO.prototype.findRation = function (repId, keyword, callback) {
|
|
|
- rationItemModel.find({'rationRepId': repId,
|
|
|
+ var filter = {
|
|
|
+ 'rationRepId': repId,
|
|
|
'$and': [{
|
|
|
- '$or': [{'code': /keyword/}, {'name': /keyword/}]
|
|
|
+ '$or': [{'code':{'$regex': keyword}}, {'name': {'$regex': keyword}}]
|
|
|
}, {
|
|
|
- '$or': [{'isDeleted': null}, {'isDeleted': false}]
|
|
|
+ '$or': [{'isDeleted': {"$exists":false}}, {'isDeleted': null}, {'isDeleted': false}]
|
|
|
}]
|
|
|
- }, function (err, data) {
|
|
|
+ };
|
|
|
+ rationItemModel.find(filter, function (err, data) {
|
|
|
if (err) {
|
|
|
callback(true, 'Fail to find ration', null);
|
|
|
} else {
|