uuid.js 777 B

12345678910111213141516171819202122232425262728293031323334
  1. import { entityKind } from "../../entity.js";
  2. import { sql } from "../../sql/sql.js";
  3. import { PgColumn, PgColumnBuilder } from "./common.js";
  4. class PgUUIDBuilder extends PgColumnBuilder {
  5. static [entityKind] = "PgUUIDBuilder";
  6. constructor(name) {
  7. super(name, "string", "PgUUID");
  8. }
  9. /**
  10. * Adds `default gen_random_uuid()` to the column definition.
  11. */
  12. defaultRandom() {
  13. return this.default(sql`gen_random_uuid()`);
  14. }
  15. /** @internal */
  16. build(table) {
  17. return new PgUUID(table, this.config);
  18. }
  19. }
  20. class PgUUID extends PgColumn {
  21. static [entityKind] = "PgUUID";
  22. getSQLType() {
  23. return "uuid";
  24. }
  25. }
  26. function uuid(name) {
  27. return new PgUUIDBuilder(name ?? "");
  28. }
  29. export {
  30. PgUUID,
  31. PgUUIDBuilder,
  32. uuid
  33. };
  34. //# sourceMappingURL=uuid.js.map