정제훈
정제훈
DTDrizzle Team
Created by 정제훈 on 10/26/2024 in #help
How can I properly compile the type of schema?
exporting like this from db repo fixes it!
6 replies
DTDrizzle Team
Created by 정제훈 on 10/26/2024 in #help
How can I properly compile the type of schema?
export * from "drizzle-orm";
export * from "drizzle-orm/postgres-js";
import postgres from "postgres";
export { postgres };
export * from "drizzle-orm";
export * from "drizzle-orm/postgres-js";
import postgres from "postgres";
export { postgres };
6 replies
DTDrizzle Team
Created by 정제훈 on 10/26/2024 in #help
How can I properly compile the type of schema?
Oh, actually it still gives a problem without compile. directly export raw ts file doesn't do anything.
6 replies
DTDrizzle Team
Created by 정제훈 on 10/26/2024 in #help
How can I properly compile the type of schema?
and importing from this .d.ts file doesn't reproduce same result when importing like import * from "./schema"
6 replies
DTDrizzle Team
Created by 정제훈 on 10/26/2024 in #help
How can I properly compile the type of schema?
// schema.ts
import { pgEnum, pgTable, text, timestamp, unique } from "drizzle-orm/pg-core";

export const providerTypeEnum = pgEnum("providerType", [
"google",
"naver",
"kakao",
"apple",
]);

export const users = pgTable(
"user",
{
id: text().primaryKey().notNull(),
providerType: providerTypeEnum("provider_type").notNull(),
providerId: text().notNull(),
username: text().notNull(),
email: text().notNull(),
avatar: text(),
},
(t) => ({
unique: unique().on(t.providerId, t.providerType),
}),
);

export const sessions = pgTable("session", {
id: text().primaryKey().notNull(),
userId: text()
.notNull()
.references(() => users.id),
expiresAt: timestamp({ mode: "date" }).notNull(),
});
// schema.ts
import { pgEnum, pgTable, text, timestamp, unique } from "drizzle-orm/pg-core";

export const providerTypeEnum = pgEnum("providerType", [
"google",
"naver",
"kakao",
"apple",
]);

export const users = pgTable(
"user",
{
id: text().primaryKey().notNull(),
providerType: providerTypeEnum("provider_type").notNull(),
providerId: text().notNull(),
username: text().notNull(),
email: text().notNull(),
avatar: text(),
},
(t) => ({
unique: unique().on(t.providerId, t.providerType),
}),
);

export const sessions = pgTable("session", {
id: text().primaryKey().notNull(),
userId: text()
.notNull()
.references(() => users.id),
expiresAt: timestamp({ mode: "date" }).notNull(),
});
compiles to
6 replies