mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
16 lines
451 B
TypeScript
16 lines
451 B
TypeScript
|
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
|
||
|
|
||
|
export async function getDatabase(typeormDb?: string): Promise<HomeDBManager> {
|
||
|
const origTypeormDB = process.env.TYPEORM_DATABASE;
|
||
|
if (typeormDb) {
|
||
|
process.env.TYPEORM_DATABASE = typeormDb;
|
||
|
}
|
||
|
const db = new HomeDBManager();
|
||
|
await db.connect();
|
||
|
await db.initializeSpecialIds();
|
||
|
if (origTypeormDB) {
|
||
|
process.env.TYPEORM_DATABASE = origTypeormDB;
|
||
|
}
|
||
|
return db;
|
||
|
}
|