interval.cjs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var interval_exports = {};
  20. __export(interval_exports, {
  21. PgInterval: () => PgInterval,
  22. PgIntervalBuilder: () => PgIntervalBuilder,
  23. interval: () => interval
  24. });
  25. module.exports = __toCommonJS(interval_exports);
  26. var import_entity = require("../../entity.cjs");
  27. var import_utils = require("../../utils.cjs");
  28. var import_common = require("./common.cjs");
  29. class PgIntervalBuilder extends import_common.PgColumnBuilder {
  30. static [import_entity.entityKind] = "PgIntervalBuilder";
  31. constructor(name, intervalConfig) {
  32. super(name, "string", "PgInterval");
  33. this.config.intervalConfig = intervalConfig;
  34. }
  35. /** @internal */
  36. build(table) {
  37. return new PgInterval(table, this.config);
  38. }
  39. }
  40. class PgInterval extends import_common.PgColumn {
  41. static [import_entity.entityKind] = "PgInterval";
  42. fields = this.config.intervalConfig.fields;
  43. precision = this.config.intervalConfig.precision;
  44. getSQLType() {
  45. const fields = this.fields ? ` ${this.fields}` : "";
  46. const precision = this.precision ? `(${this.precision})` : "";
  47. return `interval${fields}${precision}`;
  48. }
  49. }
  50. function interval(a, b = {}) {
  51. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  52. return new PgIntervalBuilder(name, config);
  53. }
  54. // Annotate the CommonJS export names for ESM import in node:
  55. 0 && (module.exports = {
  56. PgInterval,
  57. PgIntervalBuilder,
  58. interval
  59. });
  60. //# sourceMappingURL=interval.cjs.map