sort by new query structure

This commit is contained in:
Julian Krauser 2025-04-15 10:02:15 +02:00
parent 16f6846d89
commit dbafd568dd
2 changed files with 34 additions and 17 deletions

View file

@ -1,9 +1,10 @@
export interface DynamicQueryStructure {
id: string;
select: string[] | "*";
table: string;
where?: Array<ConditionStructure>;
join?: Array<DynamicQueryStructure & { foreignColumn: string }>;
orderBy?: Array<OrderByStructure>;
orderBy?: Array<OrderByStructure>; // only at top level
}
export type ConditionStructure = (
@ -48,6 +49,9 @@ export type WhereOperation =
// TODO: age between | age equals | age greater | age smaller
export type OrderByStructure = {
id: string;
depth: number;
table: string;
column: string;
order: OrderByType;
};
@ -59,6 +63,7 @@ export type QueryResult = {
};
export const exampleQuery: DynamicQueryStructure = {
id: "1234",
select: ["firstname", "lastname"],
table: "member",
where: [
@ -92,16 +97,19 @@ export const exampleQuery: DynamicQueryStructure = {
],
join: [
{
id: "5678",
select: "*",
table: "communication",
foreignColumn: "sendNewsletter",
},
{
id: "91011",
select: "*",
table: "membership",
foreignColumn: "memberships",
join: [
{
id: "121314",
select: "*",
table: "membership_status",
foreignColumn: "status",
@ -120,10 +128,16 @@ export const exampleQuery: DynamicQueryStructure = {
],
orderBy: [
{
id: "1234",
depth: 0,
table: "member",
column: "firstname",
order: "ASC",
},
{
id: "1234",
depth: 0,
table: "member",
column: "lastname",
order: "ASC",
},