Open3

SQLite (D1) でms単位のタイムスタンプを扱う方法

いしはるいしはる

created_at integer DEFAULT (unixepoch('now', 'subsec') * 1000) NOT NULL
以上

いしはるいしはる

drizzleだとこんな感じ?

export const timestamps = {
	createdAt: integer("created_at", { mode: "timestamp_ms" })
		.notNull()
		.default(sql`(unixepoch('now', 'subsec') * 1000)`),
	updatedAt: integer("updated_at", { mode: "timestamp_ms" })
		.notNull()
		.default(sql`(unixepoch('now', 'subsec') * 1000)`)
		.$onUpdateFn(() => new Date()),
};