base controller layout
This commit is contained in:
parent
6fd2091a7e
commit
ee0d6ddcce
7 changed files with 128 additions and 16 deletions
|
@ -1,14 +1,23 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { DynamicQueryStructure } from "../type/dynamicQueries";
|
||||
import { TableMeta } from "../type/tableMeta";
|
||||
|
||||
export default abstract class DynamicQueryBuilder {
|
||||
public static buildQuery(query: DynamicQueryStructure) {}
|
||||
public static allowedTables: Array<string> = [
|
||||
"award",
|
||||
"communication",
|
||||
"communicationType",
|
||||
"executivePosition",
|
||||
"membershipStatus",
|
||||
"qualification",
|
||||
"member",
|
||||
"memberAwards",
|
||||
"memberExecutivePositions",
|
||||
"memberQualifications",
|
||||
"membership",
|
||||
];
|
||||
|
||||
// use switch... for compare functions
|
||||
// use NotBrackets/Brackets for nested conditions
|
||||
// use joins by requesting table schema and setting correct column
|
||||
|
||||
public static getTableMeta(tableName: string) {
|
||||
public static getTableMeta(tableName: string): TableMeta {
|
||||
let { name, columns, relations } = dataSource.getMetadata(tableName);
|
||||
|
||||
const uniqueColumns = columns.map((c) => ({ column: c.propertyName, type: c.type }));
|
||||
|
@ -31,4 +40,19 @@ export default abstract class DynamicQueryBuilder {
|
|||
})),
|
||||
};
|
||||
}
|
||||
|
||||
public static getAllTableMeta(): Array<TableMeta> {
|
||||
return this.allowedTables.map((table) => this.getTableMeta(table));
|
||||
}
|
||||
|
||||
public static buildQuery(query: DynamicQueryStructure, offset: number = 0, count: number = 25) {
|
||||
// execute:
|
||||
// .offset(offset)
|
||||
// .limit(count)
|
||||
// .getManyAndCount()
|
||||
}
|
||||
|
||||
// use switch... for compare functions
|
||||
// use NotBrackets/Brackets for nested conditions
|
||||
// use joins by requesting table schema and setting correct column
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue