#5-intelligent-groups #23

Merged
jkeffects merged 16 commits from #5-intelligent-groups into main 2024-12-19 09:50:45 +00:00
Showing only changes of commit f05adbd430 - Show all commits

View file

@ -1,22 +1,27 @@
export interface DynamicQueryStructure {
select: string[] | "*";
table: string;
where?: Partial<ConditionStructure>;
where?: Array<ConditionStructure>;
join?: Array<DynamicQueryStructure & { foreignColumn: string }>;
orderBy?: { [key: string]: "ASC" | "DESC" };
}
export type ConditionStructure = {
[opt in WhereOptions]: Partial<ConditionStructure> | { [column: string]: Partial<ConditionOperation> };
};
export type ConditionOperation = {
[op in WhereOperation]: FieldType | Array<FieldType> | { start: FieldType; end: FieldType };
export type ConditionStructure =
| {
type: WhereType;
column: string;
operation: WhereOperation;
value: ConditionValue;
}
| {
type: WhereType;
condition: Array<ConditionStructure>;
};
export type ConditionValue = FieldType | Array<FieldType> | { start: FieldType; end: FieldType };
export type FieldType = number | string | Date | boolean;
export type WhereOptions = "OR" | "AND";
export type WhereType = "OR" | "AND" | "_";
export type WhereOperation =
| "eq" // Equal
@ -38,15 +43,31 @@ export type WhereOperation =
const exampleQuery: DynamicQueryStructure = {
select: ["firstname", "lastname"],
table: "member",
where: {
AND: {
mail: { endsWith: "@gmail.com" },
OR: {
firstname: { startsWith: "J" },
lastname: { endsWith: "K" },
where: [
{
type: "_",
column: "mail",
operation: "endsWith",
value: "@gmail.com",
},
{
type: "AND",
condition: [
{
type: "_",
column: "firstname",
operation: "startsWith",
value: "J",
},
{
type: "OR",
column: "lastname",
operation: "startsWith",
value: "K",
},
],
},
],
join: [
{
select: "*",