smallint.js 818 B

12345678910111213141516171819202122232425262728293031323334
  1. import { entityKind } from "../../entity.js";
  2. import { PgColumn } from "./common.js";
  3. import { PgIntColumnBaseBuilder } from "./int.common.js";
  4. class PgSmallIntBuilder extends PgIntColumnBaseBuilder {
  5. static [entityKind] = "PgSmallIntBuilder";
  6. constructor(name) {
  7. super(name, "number", "PgSmallInt");
  8. }
  9. /** @internal */
  10. build(table) {
  11. return new PgSmallInt(table, this.config);
  12. }
  13. }
  14. class PgSmallInt extends PgColumn {
  15. static [entityKind] = "PgSmallInt";
  16. getSQLType() {
  17. return "smallint";
  18. }
  19. mapFromDriverValue = (value) => {
  20. if (typeof value === "string") {
  21. return Number(value);
  22. }
  23. return value;
  24. };
  25. }
  26. function smallint(name) {
  27. return new PgSmallIntBuilder(name ?? "");
  28. }
  29. export {
  30. PgSmallInt,
  31. PgSmallIntBuilder,
  32. smallint
  33. };
  34. //# sourceMappingURL=smallint.js.map