bigserial.cjs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 bigserial_exports = {};
  20. __export(bigserial_exports, {
  21. PgBigSerial53: () => PgBigSerial53,
  22. PgBigSerial53Builder: () => PgBigSerial53Builder,
  23. PgBigSerial64: () => PgBigSerial64,
  24. PgBigSerial64Builder: () => PgBigSerial64Builder,
  25. bigserial: () => bigserial
  26. });
  27. module.exports = __toCommonJS(bigserial_exports);
  28. var import_entity = require("../../entity.cjs");
  29. var import_utils = require("../../utils.cjs");
  30. var import_common = require("./common.cjs");
  31. class PgBigSerial53Builder extends import_common.PgColumnBuilder {
  32. static [import_entity.entityKind] = "PgBigSerial53Builder";
  33. constructor(name) {
  34. super(name, "number", "PgBigSerial53");
  35. this.config.hasDefault = true;
  36. this.config.notNull = true;
  37. }
  38. /** @internal */
  39. build(table) {
  40. return new PgBigSerial53(
  41. table,
  42. this.config
  43. );
  44. }
  45. }
  46. class PgBigSerial53 extends import_common.PgColumn {
  47. static [import_entity.entityKind] = "PgBigSerial53";
  48. getSQLType() {
  49. return "bigserial";
  50. }
  51. mapFromDriverValue(value) {
  52. if (typeof value === "number") {
  53. return value;
  54. }
  55. return Number(value);
  56. }
  57. }
  58. class PgBigSerial64Builder extends import_common.PgColumnBuilder {
  59. static [import_entity.entityKind] = "PgBigSerial64Builder";
  60. constructor(name) {
  61. super(name, "bigint", "PgBigSerial64");
  62. this.config.hasDefault = true;
  63. }
  64. /** @internal */
  65. build(table) {
  66. return new PgBigSerial64(
  67. table,
  68. this.config
  69. );
  70. }
  71. }
  72. class PgBigSerial64 extends import_common.PgColumn {
  73. static [import_entity.entityKind] = "PgBigSerial64";
  74. getSQLType() {
  75. return "bigserial";
  76. }
  77. // eslint-disable-next-line unicorn/prefer-native-coercion-functions
  78. mapFromDriverValue(value) {
  79. return BigInt(value);
  80. }
  81. }
  82. function bigserial(a, b) {
  83. const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
  84. if (config.mode === "number") {
  85. return new PgBigSerial53Builder(name);
  86. }
  87. return new PgBigSerial64Builder(name);
  88. }
  89. // Annotate the CommonJS export names for ESM import in node:
  90. 0 && (module.exports = {
  91. PgBigSerial53,
  92. PgBigSerial53Builder,
  93. PgBigSerial64,
  94. PgBigSerial64Builder,
  95. bigserial
  96. });
  97. //# sourceMappingURL=bigserial.cjs.map