mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Moved code into src folder. Added build for component library.
This commit is contained in:
parent
7a7233ead4
commit
ede658771e
490 changed files with 749 additions and 442 deletions
41
lib/db.js
41
lib/db.js
|
|
@ -1,41 +0,0 @@
|
|||
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);
|
||||
};
|
||||
|
||||
export function getDatabaseType(url = process.env.DATABASE_URL) {
|
||||
const type = url && url.split(':')[0];
|
||||
|
||||
if (type === 'postgres') {
|
||||
return POSTGRESQL;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
export async function runQuery(queries) {
|
||||
const db = getDatabaseType(process.env.CLICKHOUSE_URL || process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL || db === MYSQL) {
|
||||
return queries[PRISMA]();
|
||||
}
|
||||
|
||||
if (db === CLICKHOUSE) {
|
||||
if (queries[KAFKA]) {
|
||||
return queries[KAFKA]();
|
||||
}
|
||||
|
||||
return queries[CLICKHOUSE]();
|
||||
}
|
||||
}
|
||||
|
||||
export function notImplemented() {
|
||||
throw new Error('Not implemented.');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue