UNPKG

789 BJavaScriptView Raw
1/**
2 * The function for building the filter string (WIP)
3 * @param {*} predicate
4 * @param {*} operation
5 * @param {*} values
6 */
7function buildFilterString(predicate, operation, values) {
8 if (Array.isArray(values)) {
9 throw new Error(
10 `The filter implementation implementations is very naive and only support comparison for now.
11 Please create an issue with the below output https://github.com/scanf/squidex-client-manager/issues/new
12 ${JSON.stringify({ predicate, values, operation }, null, 2)}
13 `,
14 );
15 }
16
17 let check = `'${values}'`;
18 if (typeof values === 'number') {
19 check = values;
20 } else if (values === null) {
21 check = null;
22 }
23
24 return `${predicate} ${operation} ${check}`;
25}
26
27module.exports.buildFilterString = buildFilterString;