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 · PostgreSQL · all subjects

batch-api

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

db.batch API for Neon HTTP driver

The Drizzle batch API allows running multiple SQL statements in a batch with the Neon HTTP driver for PostgreSQL. Call db.batch() with an array of query builders. The return type is a tuple where each element corresponds to the result of each query in the input array.

Batch API query builders supported

The db.batch API accepts the following query builders: db.query.<table>.findMany(), db.query.<table>.findFirst(), db.select()..., db.update()..., db.delete()..., and db.insert()...

Batch API example with insert, update, and select

Example of using db.batch with multiple operations: const batchResponse = await db.batch([ db.insert(usersTable).values({ id: 1, name: 'John' }).returning({ id: usersTable.id }), db.update(usersTable).set({ name: 'Dan' }).where(eq(usersTable.id, 1)), db.query.usersTable.findMany({}), db.select().from(usersTable).where(eq(usersTable.id, 1)), db.select({ id: usersTable.id, invitedBy: usersTable.invitedBy }).from(usersTable), ]); The response is a tuple where each element is the result of the corresponding query. Insert with returning() returns an array of selected columns, update returns a NeonHttpQueryResult, findMany() returns an array of full rows, and selects return arrays of the selected columns.

Give your agent this brain