text.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { entityKind } from "../../entity.js";
  2. import { getColumnNameAndConfig } from "../../utils.js";
  3. import { MySqlColumn, MySqlColumnBuilder } from "./common.js";
  4. class MySqlTextBuilder extends MySqlColumnBuilder {
  5. static [entityKind] = "MySqlTextBuilder";
  6. constructor(name, textType, config) {
  7. super(name, "string", "MySqlText");
  8. this.config.textType = textType;
  9. this.config.enumValues = config.enum;
  10. }
  11. /** @internal */
  12. build(table) {
  13. return new MySqlText(table, this.config);
  14. }
  15. }
  16. class MySqlText extends MySqlColumn {
  17. static [entityKind] = "MySqlText";
  18. textType = this.config.textType;
  19. enumValues = this.config.enumValues;
  20. getSQLType() {
  21. return this.textType;
  22. }
  23. }
  24. function text(a, b = {}) {
  25. const { name, config } = getColumnNameAndConfig(a, b);
  26. return new MySqlTextBuilder(name, "text", config);
  27. }
  28. function tinytext(a, b = {}) {
  29. const { name, config } = getColumnNameAndConfig(a, b);
  30. return new MySqlTextBuilder(name, "tinytext", config);
  31. }
  32. function mediumtext(a, b = {}) {
  33. const { name, config } = getColumnNameAndConfig(a, b);
  34. return new MySqlTextBuilder(name, "mediumtext", config);
  35. }
  36. function longtext(a, b = {}) {
  37. const { name, config } = getColumnNameAndConfig(a, b);
  38. return new MySqlTextBuilder(name, "longtext", config);
  39. }
  40. export {
  41. MySqlText,
  42. MySqlTextBuilder,
  43. longtext,
  44. mediumtext,
  45. text,
  46. tinytext
  47. };
  48. //# sourceMappingURL=text.js.map