Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
391 B
2
Indexable
Never
const whereClause = $filters$
	.map(({ field, value, exactMatch }) => {
		let operator = '=';
		let useValue = value;

		if (!exactMatch) {
			operator = 'LIKE';
			useValue = `%${useValue}%`;
		}

		if (typeof(value) === 'string')
			useValue  = `'${useValue}'`;

		const result = `${field} ${operator} ${useValue}`;

		return result;
	})
	.join(' AND ');

whereClause;