Operators and Sequelize
Sequelize is a powerful library in Javascript that makes it easy to manage a SQL database.
Read more about Sequelize
Check out more about Operators
You can also build custom queries using symbol operators.
Learn more about Symbol Operators
const Op = { eq: Symbol.for("="), ne: Symbol.for("!="), gte: Symbol.for(">="), gt: Symbol.for(">"), lte: Symbol.for("<="), lt: Symbol.for("<"), and: Symbol.for(" and "), or: Symbol.for(" or "), not: Symbol.for(" not "), like: Symbol.for(" like "), in: Symbol.for(" in "), between: Symbol.for(" between "), }; _fn function _fn(fnName, fnCol, fnOpts) {
Usage example in widgets and apps
const filter = { ["s3::date"]: { [Op.gte]: dateStr, }, };
buildFilter function structure
function buildFilter(filter) { let s = ""; const logicalOperators = Object.getOwnPropertySymbols(filter); if (logicalOperators.length > 0) { let logicalOP = logicalOperators[0]; Object.keys(filter[logicalOP]).forEach((k, ii) => { Object.getOwnPropertySymbols(filter[logicalOP][k]).forEach((e, i) => { if (ii > 0) { s += Symbol.keyFor(logicalOP) + k; } else { s += k; } s = opCheck(s, e, filter[logicalOP][k][e]); }); }); } else { Object.keys(filter).forEach((k) => { s += k; Object.getOwnPropertySymbols(filter[k]).forEach((e, i) => { if ([Op.and, Op.or, Op.not].indexOf(e) > -1) { let logicalOP = e; Object.getOwnPropertySymbols(filter[k][e]).forEach((ee, ii) => { if (ii > 0) { s += Symbol.keyFor(logicalOP) + k; } s = opCheck(s, ee, filter[k][e][ee]); }); } else if (i > 0) { //console.log("ERROR 1"); throw new Error("Logical operator error"); } else { s = opCheck(s, e, filter[k][e]); } //s += Symbol.keyFor(e) + filter[k][e]; }); //console.log(Object.getOwnPropertySymbols(filter)); /* Object.keys(filter[k]).forEach((o) => { console.log("OP ", o); }); */ }); } return s; }