expressions.js 852 B

123456789101112131415161718192021222324252627282930
  1. import { bindIfParam } from "../sql/expressions/index.js";
  2. import { sql } from "../sql/sql.js";
  3. export * from "../sql/expressions/index.js";
  4. function concat(column, value) {
  5. return sql`${column} || ${bindIfParam(value, column)}`;
  6. }
  7. function substring(column, { from, for: _for }) {
  8. const chunks = [sql`substring(`, column];
  9. if (from !== void 0) {
  10. chunks.push(sql` from `, bindIfParam(from, column));
  11. }
  12. if (_for !== void 0) {
  13. chunks.push(sql` for `, bindIfParam(_for, column));
  14. }
  15. chunks.push(sql`)`);
  16. return sql.join(chunks);
  17. }
  18. function dotProduct(column, value) {
  19. return sql`${column} <*> ${JSON.stringify(value)}`;
  20. }
  21. function euclideanDistance(column, value) {
  22. return sql`${column} <-> ${JSON.stringify(value)}`;
  23. }
  24. export {
  25. concat,
  26. dotProduct,
  27. euclideanDistance,
  28. substring
  29. };
  30. //# sourceMappingURL=expressions.js.map