File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
adminforth/dataConnectors Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,36 @@ class ClickhouseConnector extends AdminForthBaseConnector implements IAdminForth
3030 // }
3131 } ) ;
3232 }
33-
33+ async getAllTables ( ) : Promise < Array < string > > {
34+ const res = await this . client . query ( {
35+ query : `
36+ SELECT name
37+ FROM system.tables
38+ WHERE database = '${ this . dbName } '
39+ ` ,
40+ format : 'JSON' ,
41+ } ) ;
42+ const jsonResult = await res . json ( ) ;
43+ return jsonResult . data . map ( ( row : any ) => row . name ) ;
44+ }
45+
46+ async getAllColumnsInTable ( tableName : string ) : Promise < string [ ] > {
47+ const res = await this . client . query ( {
48+ query : `
49+ SELECT name
50+ FROM system.columns
51+ WHERE database = '${ this . dbName } ' AND table = {table:String}
52+ ` ,
53+ format : 'JSON' ,
54+ query_params : {
55+ table : tableName ,
56+ } ,
57+ } ) ;
58+
59+ const jsonResult = await res . json ( ) ;
60+ return jsonResult . data . map ( ( row : any ) => row . name ) ;
61+ }
62+
3463 async discoverFields ( resource : AdminForthResource ) : Promise < { [ key : string ] : AdminForthResourceColumn } > {
3564 const tableName = resource . table ;
3665
You can’t perform that action at this time.
0 commit comments