squidex-client-manager
Version:
a client for interacting with the Squidex API
28 lines (24 loc) • 789 B
JavaScript
/**
* The function for building the filter string (WIP)
* @param {*} predicate
* @param {*} operation
* @param {*} values
*/
function buildFilterString(predicate, operation, values) {
if (Array.isArray(values)) {
throw new Error(
`The filter implementation implementations is very naive and only support comparison for now.
Please create an issue with the below output https://github.com/scanf/squidex-client-manager/issues/new
${JSON.stringify({ predicate, values, operation }, null, 2)}
`,
);
}
let check = `'${values}'`;
if (typeof values === 'number') {
check = values;
} else if (values === null) {
check = null;
}
return `${predicate} ${operation} ${check}`;
}
module.exports.buildFilterString = buildFilterString;