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

mysql/column-types

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.

MySQL defaultNow() for current timestamp

Use the `defaultNow()` method on a timestamp column to set the current timestamp as the default value in MySQL. This generates a SQL DEFAULT clause with `now()` function, returning YYYY-MM-DD HH-MM-SS format.

MySQL timestamp with sql operator and now()

Use `.default(sql`now()`)` on a timestamp column with mode 'string' to set the current timestamp as default in MySQL. Values with 'string' mode are treated as strings in the application but stored as timestamps in the database.

MySQL timestamp fsp option for fractional seconds

The `fsp` option on timestamp columns in MySQL defines the number of fractional seconds to include in the timestamp. The default value is 0. Use `.timestamp('name', { fsp: 3 })` for 3 digits of fractional seconds precision, and `.default(sql`now(3)`)` to match.

MySQL unix timestamp default with unix_timestamp()

To set unix timestamp (seconds since 1970-01-01) as default on an integer column in MySQL, use `.default(sql`(unix_timestamp())`)`. This returns the number of seconds since the Unix epoch.

MySQL timestamp mode option

The `mode` option on timestamp columns in MySQL defines how values are handled in the application. The default mode (not specified) returns Date objects; 'string' mode returns strings. Both are stored as timestamps in the database.

MySQL unix timestamp default example

Example of setting unix timestamp default in MySQL: ```ts import { sql } from 'drizzle-orm'; import { mysqlTable, serial, int } from 'drizzle-orm/mysql-core'; export const users = mysqlTable('users', { id: serial('id').primaryKey(), timestamp: int('timestamp') .notNull() .default(sql`(unix_timestamp())`), }); ```

Give your agent this brain