This commit is contained in:
Brian Cao 2022-08-26 22:01:40 -07:00
parent b29cece7ef
commit 5f7b6e8ccf

View File

@ -42,7 +42,7 @@ if (process.env.NODE_ENV !== 'production') {
export { prisma };
export function getDateQuery(field, unit, timezone) {
const db = getDatabase(process.env.DATABASE_URL);
const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE);
if (db === POSTGRESQL) {
if (timezone) {
@ -63,7 +63,7 @@ export function getDateQuery(field, unit, timezone) {
}
export function getTimestampInterval(field) {
const db = getDatabase(process.env.DATABASE_URL);
const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE);
if (db === POSTGRESQL) {
return `floor(extract(epoch from max(${field}) - min(${field})))`;
@ -164,7 +164,7 @@ export async function runQuery(query) {
}
export async function rawQuery(query, params = []) {
const db = getDatabase(process.env.DATABASE_URL);
const db = getDatabase(process.env.DATABASE_URL, process.env.DATABASE_TYPE);
if (db !== POSTGRESQL && db !== MYSQL) {
return Promise.reject(new Error('Unknown database.'));