| 633 | * @category uuid |
| 634 | */ |
| 635 | export const UuidV4WithGenerate = <B extends string | symbol>( |
| 636 | schema: Schema.brand<typeof Schema.Uint8ArrayFromSelf, B> |
| 637 | ): VariantSchema.Overrideable<Uint8Array & Brand<B>, Uint8Array> => |
| 638 | VariantSchema.Overrideable(Schema.Uint8ArrayFromSelf, schema, { |
| 639 | generate: Option.match({ |
| 640 | onNone: () => Effect.sync(() => Uuid.v4({}, new Uint8Array(16))), |
| 641 | onSome: (id) => Effect.succeed(id as any) |
| 642 | }), |
| 643 | decode: Schema.Uint8ArrayFromSelf, |
| 644 | constructorDefault: () => Uuid.v4({}, new Uint8Array(16)) as any |
| 645 | }) |
| 646 | |
| 647 | /** |
| 648 | * A field that represents a binary UUID v4 that is generated on inserts. |