char.js 937 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { entityKind } from "../../entity.js";
  2. import { getColumnNameAndConfig } from "../../utils.js";
  3. import { PgColumn, PgColumnBuilder } from "./common.js";
  4. class PgCharBuilder extends PgColumnBuilder {
  5. static [entityKind] = "PgCharBuilder";
  6. constructor(name, config) {
  7. super(name, "string", "PgChar");
  8. this.config.length = config.length;
  9. this.config.enumValues = config.enum;
  10. }
  11. /** @internal */
  12. build(table) {
  13. return new PgChar(
  14. table,
  15. this.config
  16. );
  17. }
  18. }
  19. class PgChar extends PgColumn {
  20. static [entityKind] = "PgChar";
  21. length = this.config.length;
  22. enumValues = this.config.enumValues;
  23. getSQLType() {
  24. return this.length === void 0 ? `char` : `char(${this.length})`;
  25. }
  26. }
  27. function char(a, b = {}) {
  28. const { name, config } = getColumnNameAndConfig(a, b);
  29. return new PgCharBuilder(name, config);
  30. }
  31. export {
  32. PgChar,
  33. PgCharBuilder,
  34. char
  35. };
  36. //# sourceMappingURL=char.js.map