new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle · SQLite · all subjects

query api - basic queries

4 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Declare views with inline query builder syntax

Views can be declared using inline query builder syntax with sqliteView(). The view name is passed as a string, followed by .as() which takes a callback function. The callback receives the query builder and returns a select statement. View columns schema is automatically inferred from the query builder. Example: export const userView = sqliteView('user_view').as((qb) => qb.select().from(user));

Declare views with standalone query builder

Views can be declared using a standalone QueryBuilder instance. First create a QueryBuilder instance: const qb = new QueryBuilder();. Then declare the view with sqliteView(viewName).as(() => qb.select().from(table)). This works the same way as inline query builders but allows reusing the QueryBuilder instance. View columns schema is automatically inferred.

Auto-infer view columns schema from query builder

When views are created with inline or standalone query builders, the view columns schema is automatically inferred from the select statement. The developer does not need to manually declare column definitions.

Declare existing views with .existing()

To reference a view that already exists in the database and has read-only access, use the .existing() method on the view definition. This tells drizzle-kit to ignore the view and not generate a CREATE VIEW statement in migrations. Example: export const trimmedUser = sqliteView('trimmed_user', { id: integer('id'), name: text('name'), email: text('email') }).existing();

Give your agent this brain