time.js 889 B

1234567891011121314151617181920212223242526272829303132
  1. import { entityKind } from "../../entity.js";
  2. import { getColumnNameAndConfig } from "../../utils.js";
  3. import { MySqlColumn, MySqlColumnBuilder } from "./common.js";
  4. class MySqlTimeBuilder extends MySqlColumnBuilder {
  5. static [entityKind] = "MySqlTimeBuilder";
  6. constructor(name, config) {
  7. super(name, "string", "MySqlTime");
  8. this.config.fsp = config?.fsp;
  9. }
  10. /** @internal */
  11. build(table) {
  12. return new MySqlTime(table, this.config);
  13. }
  14. }
  15. class MySqlTime extends MySqlColumn {
  16. static [entityKind] = "MySqlTime";
  17. fsp = this.config.fsp;
  18. getSQLType() {
  19. const precision = this.fsp === void 0 ? "" : `(${this.fsp})`;
  20. return `time${precision}`;
  21. }
  22. }
  23. function time(a, b) {
  24. const { name, config } = getColumnNameAndConfig(a, b);
  25. return new MySqlTimeBuilder(name, config);
  26. }
  27. export {
  28. MySqlTime,
  29. MySqlTimeBuilder,
  30. time
  31. };
  32. //# sourceMappingURL=time.js.map