date.cjs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 date_exports = {};
  20. __export(date_exports, {
  21. MySqlDate: () => MySqlDate,
  22. MySqlDateBuilder: () => MySqlDateBuilder,
  23. MySqlDateString: () => MySqlDateString,
  24. MySqlDateStringBuilder: () => MySqlDateStringBuilder,
  25. date: () => date
  26. });
  27. module.exports = __toCommonJS(date_exports);
  28. var import_entity = require("../../entity.cjs");
  29. var import_utils = require("../../utils.cjs");
  30. var import_common = require("./common.cjs");
  31. class MySqlDateBuilder extends import_common.MySqlColumnBuilder {
  32. static [import_entity.entityKind] = "MySqlDateBuilder";
  33. constructor(name) {
  34. super(name, "date", "MySqlDate");
  35. }
  36. /** @internal */
  37. build(table) {
  38. return new MySqlDate(table, this.config);
  39. }
  40. }
  41. class MySqlDate extends import_common.MySqlColumn {
  42. static [import_entity.entityKind] = "MySqlDate";
  43. constructor(table, config) {
  44. super(table, config);
  45. }
  46. getSQLType() {
  47. return `date`;
  48. }
  49. mapFromDriverValue(value) {
  50. return new Date(value);
  51. }
  52. }
  53. class MySqlDateStringBuilder extends import_common.MySqlColumnBuilder {
  54. static [import_entity.entityKind] = "MySqlDateStringBuilder";
  55. constructor(name) {
  56. super(name, "string", "MySqlDateString");
  57. }
  58. /** @internal */
  59. build(table) {
  60. return new MySqlDateString(
  61. table,
  62. this.config
  63. );
  64. }
  65. }
  66. class MySqlDateString extends import_common.MySqlColumn {
  67. static [import_entity.entityKind] = "MySqlDateString";
  68. constructor(table, config) {
  69. super(table, config);
  70. }
  71. getSQLType() {
  72. return `date`;
  73. }
  74. }
  75. function date(a, b) {
  76. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  77. if (config?.mode === "string") {
  78. return new MySqlDateStringBuilder(name);
  79. }
  80. return new MySqlDateBuilder(name);
  81. }
  82. // Annotate the CommonJS export names for ESM import in node:
  83. 0 && (module.exports = {
  84. MySqlDate,
  85. MySqlDateBuilder,
  86. MySqlDateString,
  87. MySqlDateStringBuilder,
  88. date
  89. });
  90. //# sourceMappingURL=date.cjs.map