The Drizzle table schema type.
The string keys selected from the table.
A constant mapping of column names to Drizzle operators (e.g., 'eq', 'ilike').
The Drizzle table object (e.g., users).
An array of column names to retrieve.
An object mapping column names to operators. This defines the required parameters for .execute().
A unique string identifier for this prepared statement in the Drizzle cache.
Whether to combine filters with AND or OR. Defaults to "AND".
A Drizzle Prepared Query object with an enhanced execute method that is strictly typed
to the filters and selection provided.
// 1. Create the prepared statement once (e.g., at the module level or in a constructor)
const findUserByEmail = createPrepareStatement(
users,
["id", "firstName", "email"],
{
email: "eq",
status: "eq"
},
"find_user_by_email_and_status"
);
// 2. Execute it later with specific parameters
// The 'params' argument is typed to { email: string; status: string }
const results = await executePreparedStatement(findUserByEmail, {
email: "john@doe.com",
status: "active"
});
Creates a type-safe Drizzle prepared statement for optimized, reusable database queries.
Prepared statements are pre-compiled by the database, making them faster for repeated execution. This function dynamically builds the selection and the
WHEREclause placeholders based on the providedfiltersmap.