UNPKG

betterddb

Version:

A definition-based DynamoDB wrapper library that provides a schema-driven and fully typesafe DAL.

28 lines 1.02 kB
export function getOperatorExpression(operator, nameKey, valueKey, secondValueKey) { switch (operator) { case "==": return `${nameKey} = ${valueKey}`; case "!=": return `${nameKey} <> ${valueKey}`; case "<": return `${nameKey} < ${valueKey}`; case "<=": return `${nameKey} <= ${valueKey}`; case ">": return `${nameKey} > ${valueKey}`; case ">=": return `${nameKey} >= ${valueKey}`; case "begins_with": return `begins_with(${nameKey}, ${valueKey})`; case "between": if (!secondValueKey) { throw new Error("The 'between' operator requires two value keys"); } return `${nameKey} BETWEEN ${valueKey} AND ${secondValueKey}`; case "contains": return `contains(${nameKey}, ${valueKey})`; default: throw new Error("Unsupported operator"); } } //# sourceMappingURL=operator.js.map