Untitled

 avatar
unknown
javascript
2 years ago
391 B
2
Indexable
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;