mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 20:35:59 +00:00
SYNC: Merge branch 'feature/dblogs'
This commit is contained in:
committed by
Diflow
parent
4ed437fd4e
commit
ed7605eccd
@@ -83,3 +83,44 @@ export function selectKeysFromTable(options: {
|
||||
};
|
||||
return res;
|
||||
}
|
||||
|
||||
export function createLogCompoudCondition(
|
||||
fieldFilters: { [field: string]: string[] },
|
||||
timeColumn: string,
|
||||
timeFrom: number,
|
||||
timeTo: number
|
||||
): Condition {
|
||||
const conditions: Condition[] = [
|
||||
{
|
||||
conditionType: 'binary',
|
||||
operator: '>=',
|
||||
left: { exprType: 'column', columnName: timeColumn },
|
||||
right: { exprType: 'value', value: timeFrom },
|
||||
},
|
||||
{
|
||||
conditionType: 'binary',
|
||||
operator: '<=',
|
||||
left: { exprType: 'column', columnName: timeColumn },
|
||||
right: { exprType: 'value', value: timeTo },
|
||||
},
|
||||
];
|
||||
for (const [key, values] of Object.entries(fieldFilters)) {
|
||||
if (values.length == 1 && values[0] == null) {
|
||||
conditions.push({
|
||||
conditionType: 'isNull',
|
||||
expr: { exprType: 'column', columnName: key },
|
||||
});
|
||||
continue;
|
||||
}
|
||||
conditions.push({
|
||||
conditionType: 'in',
|
||||
expr: { exprType: 'column', columnName: key },
|
||||
values,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
conditionType: 'and',
|
||||
conditions,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user