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

Source

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

Source

layer

IdentifierStore backed by drizzle, on top of DrizzleDatabase.

Signature

declare const layer: (schema?: SchemaInput) => Layer.Layer<Auth.Identifier.IdentifierStore, never, DrizzleDatabase>

Source

make

Build an IdentifierStore over the ambient DrizzleDatabase.

Signature

declare const make: (
  schema?: SchemaInput
) => Effect.Effect<typeof Auth.Identifier.IdentifierStore.Service, never, DrizzleDatabase>

Source

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>

Source

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>

Source


This site uses Just the Docs, a documentation theme for Jekyll.