Spaces:
Configuration error
Configuration error
Download src/lib/db.ts from SreejithSHR/umami: direct link, hf CLI and curl.
- Browser
- Download file 894 Bytes
-
https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/db.ts
- Command line
-
hf download hf://spaces/SreejithSHR/umami/src/lib/db.ts
-
curl -L -o db.ts https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/db.ts
894 Bytes
| 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: any) { | |
| if (process.env.CLICKHOUSE_URL) { | |
| if (queries[KAFKA]) { | |
| return queries[KAFKA](); | |
| } | |
| return queries[CLICKHOUSE](); | |
| } | |
| const db = getDatabaseType(); | |
| if (db === POSTGRESQL || db === MYSQL) { | |
| return queries[PRISMA](); | |
| } | |
| } | |
| export function notImplemented() { | |
| throw new Error('Not implemented.'); | |
| } | |