add daydiff function query
This commit is contained in:
@@ -34,6 +34,18 @@ function getAddMinutesQuery(field: string, minutes: number): string {
|
||||
}
|
||||
}
|
||||
|
||||
function getDayDiffQuery(field1: string, field2: string): string {
|
||||
const db = getDatabaseType(process.env.DATABASE_URL);
|
||||
|
||||
if (db === POSTGRESQL) {
|
||||
return `${field1}::date - ${field2}::date`;
|
||||
}
|
||||
|
||||
if (db === MYSQL) {
|
||||
return `DATEDIFF(${field1}, ${field2});`;
|
||||
}
|
||||
}
|
||||
|
||||
function getDateQuery(field: string, unit: string, timezone?: string): string {
|
||||
const db = getDatabaseType();
|
||||
|
||||
@@ -180,6 +192,7 @@ function getPageFilters(filters: SearchFilter<any>): [
|
||||
export default {
|
||||
...prisma,
|
||||
getAddMinutesQuery,
|
||||
getDayDiffQuery,
|
||||
getDateQuery,
|
||||
getTimestampIntervalQuery,
|
||||
getFilterQuery,
|
||||
|
||||
Reference in New Issue
Block a user