IdentifierStore.ts overview
Drizzle IdentifierStore and the batched identifier reads, over a dialect’s Tables or a defineSchema mapping. A unique-index violation is an AuthError, which core turns into IdentifierTakenError. replace inserts, then deletes, in no transaction of its own: outside the application’s, a failure leaves both identifiers.
Exports Grouped by Category
utils
GetIdentifierByValue (class)
Resolve one identifier by its (type, value) pair — the natural unique key. Resolves to None on a miss, exactly like IdentifierStore.getByValue. Issue it with Requests.getIdentifierByValue(type, value).
Signature
declare class GetIdentifierByValue
ListIdentifiersByUser (class)
List a user’s identifiers, ordered by createdAt ascending. Resolves to [] for a user with none, exactly like IdentifierStore.listByUser. Issue it with Requests.listIdentifiersByUser(userId).
Signature
declare class ListIdentifiersByUser
layer
IdentifierStore backed by drizzle, on top of DrizzleDatabase.
Signature
declare const layer: (schema?: SchemaInput) => Layer.Layer<Auth.Identifier.IdentifierStore, never, DrizzleDatabase>
make
Build an IdentifierStore over the ambient DrizzleDatabase.
Signature
declare const make: (
schema?: SchemaInput
) => Effect.Effect<typeof Auth.Identifier.IdentifierStore.Service, never, DrizzleDatabase>
makeByUserResolver
A resolver that collapses every ListIdentifiersByUser in a batch into a single WHERE user_id IN (...) query, then splits the rows back out per user.
The single ORDER BY created_at carries through to each user’s slice, so the batched result is ordered exactly like IdentifierStore.listByUser, and a user with no identifiers gets [] rather than a missing entry.
The returned resolver must be shared for batching to happen — requests are grouped per resolver instance. Build it once behind Requests.AuthRequests/Requests.layer rather than per call site.
Signature
declare const makeByUserResolver: (
schema?: SchemaInput
) => Effect.Effect<RequestResolver.RequestResolver<ListIdentifiersByUser>, never, DrizzleDatabase>
makeByValueResolver
A resolver that collapses every GetIdentifierByValue in a batch into a single query.
(type, value) is a composite key, so the batch is grouped by type and emitted as one OR-ed set of type = $t AND value IN (...) clauses — still a single round trip even when the batch mixes emails, usernames and phone numbers. Duplicate pairs are de-duplicated first.
The returned resolver must be shared for batching to happen — requests are grouped per resolver instance. Build it once behind Requests.AuthRequests/Requests.layer rather than per call site.
Signature
declare const makeByValueResolver: (
schema?: SchemaInput
) => Effect.Effect<RequestResolver.RequestResolver<GetIdentifierByValue>, never, DrizzleDatabase>