bigint.cjs 2.8 KB

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