expressions.cjs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
  19. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  20. var expressions_exports = {};
  21. __export(expressions_exports, {
  22. concat: () => concat,
  23. dotProduct: () => dotProduct,
  24. euclideanDistance: () => euclideanDistance,
  25. substring: () => substring
  26. });
  27. module.exports = __toCommonJS(expressions_exports);
  28. var import_expressions = require("../sql/expressions/index.cjs");
  29. var import_sql = require("../sql/sql.cjs");
  30. __reExport(expressions_exports, require("../sql/expressions/index.cjs"), module.exports);
  31. function concat(column, value) {
  32. return import_sql.sql`${column} || ${(0, import_expressions.bindIfParam)(value, column)}`;
  33. }
  34. function substring(column, { from, for: _for }) {
  35. const chunks = [import_sql.sql`substring(`, column];
  36. if (from !== void 0) {
  37. chunks.push(import_sql.sql` from `, (0, import_expressions.bindIfParam)(from, column));
  38. }
  39. if (_for !== void 0) {
  40. chunks.push(import_sql.sql` for `, (0, import_expressions.bindIfParam)(_for, column));
  41. }
  42. chunks.push(import_sql.sql`)`);
  43. return import_sql.sql.join(chunks);
  44. }
  45. function dotProduct(column, value) {
  46. return import_sql.sql`${column} <*> ${JSON.stringify(value)}`;
  47. }
  48. function euclideanDistance(column, value) {
  49. return import_sql.sql`${column} <-> ${JSON.stringify(value)}`;
  50. }
  51. // Annotate the CommonJS export names for ESM import in node:
  52. 0 && (module.exports = {
  53. concat,
  54. dotProduct,
  55. euclideanDistance,
  56. substring,
  57. ...require("../sql/expressions/index.cjs")
  58. });
  59. //# sourceMappingURL=expressions.cjs.map