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

pg-core/sequences

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

pgSequence basic creation

In Drizzle ORM for PostgreSQL, create a sequence with pgSequence("name"). This creates a sequence with default parameters.

pgSequence parameters

The pgSequence function accepts an optional second parameter with configuration object. The available options are: startWith (starting value), maxValue (maximum value), minValue (minimum value), cycle (boolean to cycle when max is reached), cache (number of values to cache), and increment (step value between numbers).

pgSequence import

Import pgSequence from "drizzle-orm/pg-core".

Sequence in custom schema

Create a sequence in a custom PostgreSQL schema by first creating a schema with pgSchema('schema_name'), then calling the .sequence("name") method on it.

Sequence basic example

Example showing pgSequence usage: ```ts import { pgSchema, pgSequence } from "drizzle-orm/pg-core"; // No params specified export const customSequence = pgSequence("name"); // Sequence with params export const customSequence = pgSequence("name", { startWith: 100, maxValue: 10000, minValue: 100, cycle: true, cache: 10, increment: 2 }); // Sequence in custom schema export const customSchema = pgSchema('custom_schema'); export const customSequence = customSchema.sequence("name"); ```

Sequences purpose in PostgreSQL

Sequences in PostgreSQL are special single-row tables created to generate unique identifiers. They are often used for auto-incrementing primary key values and provide a thread-safe way to generate unique sequential values across multiple sessions.

Give your agent this brain