use in to parse where({id: [1, 2, 3]}) in where condition

This commit is contained in:
lichengyin 2015-10-25 09:13:51 +08:00
parent 25d426fb2e
commit 7c05de0f75

View File

@ -281,6 +281,17 @@ export default class extends think.base {
throw new Error(think.locale('WHERE_CONDITION_INVALID', key, JSON.stringify(val)));
}
}else{
// where({id: [1, 2, 3]})
let flag = think.isNumber(val[0]) || think.isNumberString(val[0]);
if(flag){
flag = val.every(item => {
return think.isNumber(item) || think.isNumberString(item);
});
if(flag){
return `${key} IN ( ${val.join(', ')} )`;
}
}
let length = val.length;
let logic = this.getLogic(val[length - 1], '');
if(logic){