change: query update to v1.4.0

This commit is contained in:
Julian Krauser 2025-04-16 17:17:12 +02:00
parent 5a057af17d
commit 9e41910e9e
2 changed files with 22 additions and 2 deletions

View file

@ -1,9 +1,10 @@
export interface DynamicQueryStructure { export interface DynamicQueryStructure {
id: string;
select: string[] | "*"; select: string[] | "*";
table: string; table: string;
where?: Array<ConditionStructure>; where?: Array<ConditionStructure>;
join?: Array<DynamicQueryStructure & { foreignColumn: string }>; join?: Array<DynamicQueryStructure & JoinStructure>;
orderBy?: Array<OrderByStructure>; orderBy?: Array<OrderByStructure>; // only at top level
} }
export type ConditionStructure = ( export type ConditionStructure = (
@ -47,7 +48,12 @@ export type WhereOperation =
| "timespanEq"; // Date before x years (YYYY-01-01 <bis> YYYY-12-31) | "timespanEq"; // Date before x years (YYYY-01-01 <bis> YYYY-12-31)
// TODO: age between | age equals | age greater | age smaller // TODO: age between | age equals | age greater | age smaller
export type JoinStructure = { foreignColumn: string; type: "defined" } | { condition: string; type: "custom" };
export type OrderByStructure = { export type OrderByStructure = {
id: string;
depth: number;
table: string;
column: string; column: string;
order: OrderByType; order: OrderByType;
}; };
@ -59,6 +65,7 @@ export type QueryResult = {
}; };
export const exampleQuery: DynamicQueryStructure = { export const exampleQuery: DynamicQueryStructure = {
id: "1234",
select: ["firstname", "lastname"], select: ["firstname", "lastname"],
table: "member", table: "member",
where: [ where: [
@ -92,19 +99,25 @@ export const exampleQuery: DynamicQueryStructure = {
], ],
join: [ join: [
{ {
id: "5678",
select: "*", select: "*",
table: "communication", table: "communication",
foreignColumn: "sendNewsletter", foreignColumn: "sendNewsletter",
type: "defined",
}, },
{ {
id: "91011",
select: "*", select: "*",
table: "membership", table: "membership",
foreignColumn: "memberships", foreignColumn: "memberships",
type: "defined",
join: [ join: [
{ {
id: "121314",
select: "*", select: "*",
table: "membership_status", table: "membership_status",
foreignColumn: "status", foreignColumn: "status",
type: "defined",
where: [ where: [
{ {
structureType: "condition", structureType: "condition",
@ -120,10 +133,16 @@ export const exampleQuery: DynamicQueryStructure = {
], ],
orderBy: [ orderBy: [
{ {
id: "1234",
depth: 0,
table: "member",
column: "firstname", column: "firstname",
order: "ASC", order: "ASC",
}, },
{ {
id: "1234",
depth: 0,
table: "member",
column: "lastname", column: "lastname",
order: "ASC", order: "ASC",
}, },

View file

@ -5,6 +5,7 @@ export interface QueryViewModel {
id: string; id: string;
title: string; title: string;
query: string | DynamicQueryStructure; query: string | DynamicQueryStructure;
updatedAt: Date;
} }
export interface CreateQueryViewModel { export interface CreateQueryViewModel {