mirror of
https://github.com/umami-software/umami.git
synced 2026-02-21 04:55:36 +01:00
feat: support mongodb connection
This commit is contained in:
parent
586529a5ca
commit
bb30b43a8e
9 changed files with 370 additions and 30 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import prisma from '@umami/prisma-client';
|
||||
import moment from 'moment-timezone';
|
||||
import { MYSQL, POSTGRESQL, getDatabaseType } from 'lib/db';
|
||||
import { MYSQL, POSTGRESQL, getDatabaseType, MONGODB } from 'lib/db';
|
||||
import { getEventDataType } from './eventData';
|
||||
import { FILTER_COLUMNS } from './constants';
|
||||
|
||||
|
|
@ -51,6 +51,10 @@ function getDateQuery(field: string, unit: string, timezone?: string): string {
|
|||
|
||||
return `date_format(${field}, '${MYSQL_DATE_FORMATS[unit]}')`;
|
||||
}
|
||||
|
||||
if (db === MONGODB) {
|
||||
return MYSQL_DATE_FORMATS[unit];
|
||||
}
|
||||
}
|
||||
|
||||
function getTimestampInterval(field: string): string {
|
||||
|
|
@ -152,6 +156,7 @@ async function rawQuery(query: string, params: never[] = []): Promise<any> {
|
|||
|
||||
export default {
|
||||
...prisma,
|
||||
getDatabaseType: () => getDatabaseType(process.env.DATABASE_URL),
|
||||
getDateQuery,
|
||||
getTimestampInterval,
|
||||
getFilterQuery,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue