time.cjs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 time_exports = {};
  20. __export(time_exports, {
  21. PgTime: () => PgTime,
  22. PgTimeBuilder: () => PgTimeBuilder,
  23. time: () => time
  24. });
  25. module.exports = __toCommonJS(time_exports);
  26. var import_entity = require("../../entity.cjs");
  27. var import_utils = require("../../utils.cjs");
  28. var import_common = require("./common.cjs");
  29. var import_date_common = require("./date.common.cjs");
  30. class PgTimeBuilder extends import_date_common.PgDateColumnBaseBuilder {
  31. constructor(name, withTimezone, precision) {
  32. super(name, "string", "PgTime");
  33. this.withTimezone = withTimezone;
  34. this.precision = precision;
  35. this.config.withTimezone = withTimezone;
  36. this.config.precision = precision;
  37. }
  38. static [import_entity.entityKind] = "PgTimeBuilder";
  39. /** @internal */
  40. build(table) {
  41. return new PgTime(table, this.config);
  42. }
  43. }
  44. class PgTime extends import_common.PgColumn {
  45. static [import_entity.entityKind] = "PgTime";
  46. withTimezone;
  47. precision;
  48. constructor(table, config) {
  49. super(table, config);
  50. this.withTimezone = config.withTimezone;
  51. this.precision = config.precision;
  52. }
  53. getSQLType() {
  54. const precision = this.precision === void 0 ? "" : `(${this.precision})`;
  55. return `time${precision}${this.withTimezone ? " with time zone" : ""}`;
  56. }
  57. }
  58. function time(a, b = {}) {
  59. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  60. return new PgTimeBuilder(name, config.withTimezone ?? false, config.precision);
  61. }
  62. // Annotate the CommonJS export names for ESM import in node:
  63. 0 && (module.exports = {
  64. PgTime,
  65. PgTimeBuilder,
  66. time
  67. });
  68. //# sourceMappingURL=time.cjs.map