mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
add read replica
This commit is contained in:
parent
11232bf4f8
commit
afa48e8a6b
|
@ -1,13 +1,22 @@
|
|||
import { drizzle, NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||
import { withReplicas } from 'drizzle-orm/pg-core';
|
||||
import { Pool } from "pg";
|
||||
|
||||
function createDB() {
|
||||
if (process.env.DATABASE_URI) {
|
||||
const pool = new Pool({
|
||||
const db = drizzle(new Pool({
|
||||
connectionString: process.env.DATABASE_URI,
|
||||
})
|
||||
}))
|
||||
|
||||
return drizzle(pool);
|
||||
if (process.env.DATABASE_REPLICA_URI) {
|
||||
const replica = drizzle(new Pool({
|
||||
connectionString: process.env.DATABASE_REPLICA_URI,
|
||||
}));
|
||||
|
||||
return withReplicas(db, [replica])
|
||||
} else {
|
||||
return db;
|
||||
}
|
||||
} else {
|
||||
return { no: true };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user