File tree 1 file changed +18
-6
lines changed
1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,23 @@ export default eventHandler(async () => {
34
34
. then ( res => res . map ( ( { results } ) => results as { name : string ; type : string } [ ] ) ) ,
35
35
] )
36
36
37
- return tables . map ( ( { name } , i ) => ( {
38
- name,
39
- columns : columns [ i ] ,
40
- primaryKeys : primaryKeys [ i ] ,
41
- indexes : indexes [ i ] ,
42
- count : count [ i ]
37
+ return Promise . all ( tables . map ( async ( { name } , i ) => {
38
+ const tableIndexes = indexes [ i ]
39
+
40
+ if ( tableIndexes . length ) {
41
+ const tableIndexesColumns = await db . batch ( tableIndexes . map ( ( { name } ) => db . prepare ( `PRAGMA index_info("${ name } ")` ) ) )
42
+ . then ( res => res . map ( ( { results } ) => results ) )
43
+ tableIndexes . forEach ( ( index , i ) => {
44
+ index . columns = tableIndexesColumns [ i ] . map ( c => c . name )
45
+ } )
46
+ }
47
+
48
+ return {
49
+ name,
50
+ columns : columns [ i ] ,
51
+ primaryKeys : primaryKeys [ i ] ,
52
+ indexes : tableIndexes ,
53
+ count : count [ i ]
54
+ }
43
55
} ) )
44
56
} )
You can’t perform that action at this time.
0 commit comments