how to make date in timestamp

Hi Guys I need some help and new in drizzle, i tried using turso but i'm facing problem where the date is in epoch format how i can convert it to normal date or human readable format like datetime?
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';

export const userTable = sqliteTable('users', {
id: text('id').notNull().primaryKey(),
provider: text('provider').notNull().default('email'),
providerId: text('provider_id').notNull().default(''),
email: text('email').notNull().unique(),
firstName: text('first_name').notNull(),
lastName: text('last_name').notNull(),
role: text('role').notNull().default('USER'),
verified: integer('verified', { mode : 'boolean'}).default(false),
receiveEmail: integer('receive_email', { mode : 'boolean'}).default(true),
password: text('password'),
token: text('token').unique(),
createdAt: text('created_at').notNull(),
updatedAt: text('updated_at').notNull()
});

export const sessionTable = sqliteTable('sessions', {
id: text('id').notNull().primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id),
expiresAt: text('expires_at').notNull()
});

export type User = typeof userTable.$inferInsert;
export type UpdateUser = Partial<typeof userTable.$inferInsert>;
export type Session = typeof sessionTable.$inferInsert;
/
import { text, integer, sqliteTable } from 'drizzle-orm/sqlite-core';

export const userTable = sqliteTable('users', {
id: text('id').notNull().primaryKey(),
provider: text('provider').notNull().default('email'),
providerId: text('provider_id').notNull().default(''),
email: text('email').notNull().unique(),
firstName: text('first_name').notNull(),
lastName: text('last_name').notNull(),
role: text('role').notNull().default('USER'),
verified: integer('verified', { mode : 'boolean'}).default(false),
receiveEmail: integer('receive_email', { mode : 'boolean'}).default(true),
password: text('password'),
token: text('token').unique(),
createdAt: text('created_at').notNull(),
updatedAt: text('updated_at').notNull()
});

export const sessionTable = sqliteTable('sessions', {
id: text('id').notNull().primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id),
expiresAt: text('expires_at').notNull()
});

export type User = typeof userTable.$inferInsert;
export type UpdateUser = Partial<typeof userTable.$inferInsert>;
export type Session = typeof sessionTable.$inferInsert;
/
No description
1 Reply
Mykhailo
Mykhailo8mo ago
Drizzle ORM - SQL Timestamp as a default value
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server