Skip to main content
server.GenericQueryCtx A set of services for use within Bijection query functions. The query context is passed as the first argument to any Bijection query function run on the server. Queries are read-only, they can read from the database but cannot write. They are also reactive, when used with useQuery on the client, the result automatically updates when data changes. You should generally use the QueryCtx type from "./_generated/server". Example

Type parameters

Hierarchy

Properties

db

• db: GenericDatabaseReader<DataModel> A utility for reading data in the database. Use ctx.db.get(table, id) to fetch a single document by ID, or ctx.db.query("tableName") to query multiple documents with filtering and ordering. Queries are read-only, no write methods are available.

auth

• auth: Auth Information about the currently authenticated user. Call await ctx.auth.getUserIdentity() to get the current user’s identity, or null if the user is not authenticated.

storage

• storage: StorageReader A utility for reading files in storage. Use ctx.storage.getUrl(storageId) to get a URL for a stored file.

runQuery

• runQuery: <Query>(query: Query, …args: ArgsAndOptions<Query, { transactionLimits?: TransactionLimits }>) => Promise<FunctionReturnType<Query>>

Type declaration

▸ <Query>(query, ...args): Promise<FunctionReturnType<Query>> Call a query function within the same transaction. The query runs within the same read snapshot. Requires a FunctionReference (e.g., api.myModule.myQuery or internal.myModule.myQuery). NOTE: Often you can extract shared logic into a helper function instead. runQuery incurs overhead of running argument and return value validation, and creating a new isolated JS context.
Type parameters
Parameters
Returns
Promise<FunctionReturnType<Query>>

meta

• meta: QueryMeta