mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Database refactoring.
This commit is contained in:
parent
bb184dc2cc
commit
467c7f289f
37 changed files with 566 additions and 591 deletions
14
lib/db.js
14
lib/db.js
|
|
@ -1,5 +1,11 @@
|
|||
import { POSTGRESQL, RELATIONAL, MYSQL, KAFKA, CLICKHOUSE } from 'lib/constants';
|
||||
export const PRISMA = 'prisma';
|
||||
export const POSTGRESQL = 'postgresql';
|
||||
export const MYSQL = 'mysql';
|
||||
export const CLICKHOUSE = 'clickhouse';
|
||||
export const KAFKA = 'kafka';
|
||||
export const KAFKA_PRODUCER = 'kafka-producer';
|
||||
|
||||
// Fixes issue with converting bigint values
|
||||
BigInt.prototype.toJSON = function () {
|
||||
return Number(this);
|
||||
};
|
||||
|
|
@ -14,11 +20,11 @@ export function getDatabaseType(url = process.env.DATABASE_URL) {
|
|||
return type;
|
||||
}
|
||||
|
||||
export async function runAnalyticsQuery(queries) {
|
||||
const db = getDatabaseType(process.env.ANALYTICS_URL || process.env.DATABASE_URL);
|
||||
export async function runQuery(queries) {
|
||||
const db = getDatabaseType(process.env.CLICKHOUSE_URL || process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL || db === MYSQL) {
|
||||
return queries[RELATIONAL]();
|
||||
return queries[PRISMA]();
|
||||
}
|
||||
|
||||
if (db === CLICKHOUSE) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue