traxxx/src/utils/where-or.js

26 lines
494 B
JavaScript
Raw Normal View History

'use strict';
function whereOr(query, table, builder) {
if (!query) {
return {};
}
Object.entries(query).forEach(([key, value]) => {
if (value === undefined) {
return builder;
}
if (Array.isArray(value)) {
builder.orWhereIn(`${table}.${key}`, value);
return builder;
}
builder.orWhere(`${table}.${key}`, value);
return builder;
});
return builder;
}
module.exports = whereOr;