auth/account_queries.ts view source
(deps: QueryDeps, email: string): Promise<Account | undefined> Find an account by email (case-insensitive).
deps
email
stringreturns
Promise<Account | undefined> Account and actor database queries.
Provides CRUD operations for the account and actor tables. For v1, every account has exactly one actor (1:1).
13 declarations
auth/account_queries.ts view source
(deps: QueryDeps, email: string): Promise<Account | undefined> Find an account by email (case-insensitive).
depsemailstringPromise<Account | undefined> auth/account_queries.ts view source
(deps: QueryDeps, id: string): Promise<Account | undefined> Find an account by id.
depsidstringPromise<Account | undefined> auth/account_queries.ts view source
(deps: QueryDeps, username: string): Promise<Account | undefined> Find an account by username (case-insensitive).
depsusernamestringPromise<Account | undefined> auth/account_queries.ts view source
(deps: QueryDeps, input: string): Promise<Account | undefined> Find an account by username or email.
If the input contains @, tries email lookup first then username.
Otherwise tries username first then email. This supports a single
login field that accepts either format.
depsquery dependencies
inputusername or email address
stringPromise<Account | undefined> the matching account, or undefined
auth/account_queries.ts view source
(deps: QueryDeps): Promise<boolean> Check if any account exists.
depsPromise<boolean> auth/account_queries.ts view source
(deps: QueryDeps, account_id: string): Promise<Actor | undefined> Find the actor for an account.
For v1, each account has exactly one actor.
depsaccount_idstringPromise<Actor | undefined> auth/account_queries.ts view source
(deps: QueryDeps, id: string): Promise<Actor | undefined> Find an actor by id.
depsidstringPromise<Actor | undefined> auth/account_queries.ts view source
(deps: QueryDeps): Promise<{ account: { id: string; username: string; email: string | null; email_verified: boolean; created_at: string; updated_at: string; updated_by: string | null; }; actor: { ...; } | null; permits: { ...; }[]; }[]> List all accounts with their actors and active permits for admin display.
Uses 3 flat queries instead of N+1 per-account loops.
depsquery dependencies
Promise<{ account: { id: string; username: string; email: string | null; email_verified: boolean; created_at: string; updated_at: string; updated_by: string | null; }; actor: { id: string; name: string; } | null; permits: { ...; }[]; }[]> admin account entries sorted by creation date
auth/account_queries.ts view source
(deps: QueryDeps, input: CreateAccountInput): Promise<Account> Create a new account.
depsquery dependencies
inputthe account fields
Promise<Account> the created account
auth/account_queries.ts view source
(deps: QueryDeps, input: CreateAccountInput): Promise<{ account: Account; actor: Actor; }> Create an account and its actor in a single operation.
For v1, every account gets exactly one actor with the same name as the username.
depsquery dependencies
inputthe account fields
Promise<{ account: Account; actor: Actor; }> the created account and actor
auth/account_queries.ts view source
(deps: QueryDeps, account_id: string, name: string): Promise<Actor> Create a new actor for an account.
depsquery dependencies
account_idthe owning account
stringnamedisplay name (defaults to account username)
stringPromise<Actor> the created actor
auth/account_queries.ts view source
(deps: QueryDeps, id: string): Promise<boolean> Delete an account. Cascades to actors, permits, sessions, and tokens.
depsidstringPromise<boolean> auth/account_queries.ts view source
(deps: QueryDeps, id: string, password_hash: string, updated_by: string | null): Promise<void> Update the password hash for an account.
depsidstringpassword_hashstringupdated_bystring | nullPromise<void>