Skip to content

Commit

Permalink
chore(db): add type
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Jul 7, 2024
1 parent b1d6cfb commit 5581db3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"pg": "^8.11.5"
},
"dependencies": {
"postgres": "^3.4.4"
"postgres": "^3.4.4",
"@earthworm/schema": "workspace:^"
}
}
6 changes: 5 additions & 1 deletion packages/db/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import dotenv from "dotenv";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import { schemas } from "@earthworm/schema";

const envName = process.env.NODE_ENV === "prod" ? ".env.prod" : ".env";
dotenv.config({ path: path.resolve(__dirname, `../../../apps/api/${envName}`) });

console.log("connection string: ", process.env.DATABASE_URL);
const connection = postgres(process.env.DATABASE_URL ?? "");

export const db = drizzle(connection);
export const db = drizzle(connection, {
schema: schemas,
});
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5581db3

Please sign in to comment.