File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { callTsProxy, findAdminInstance } from "../callTsProxy.js";
2
2
import { toTitleCase } from '../utils.js' ;
3
3
import { generateResourceFile } from "./generateResourceFile.js" ;
4
4
import { injectResourceIntoIndex } from "./injectResourceIntoIndex.js" ;
5
- import { select } from "@inquirer/prompts" ;
5
+ import { search , Separator } from "@inquirer/prompts" ;
6
6
7
7
export default async function createResource ( args ) {
8
8
console . log ( "Bundling admin SPA..." ) ;
@@ -27,9 +27,20 @@ export default async function createResource(args) {
27
27
} ) )
28
28
) ;
29
29
30
- const table = await select ( {
31
- message : "🗂 Choose a table to generate a resource for:" ,
32
- choices : tableChoices ,
30
+ const table = await search ( {
31
+ message : '🔍 Choose a table to generate a resource for:' ,
32
+ source : async ( input = '' ) => {
33
+ const term = input . toLowerCase ( ) ;
34
+ const choices = tableChoices
35
+ . filter ( c =>
36
+ c . name . toLowerCase ( ) . includes ( term )
37
+ )
38
+ . map ( c => ( { name : c . name , value : c . value } ) ) ;
39
+ return [
40
+ ...choices ,
41
+ new Separator ( ) ,
42
+ ] ;
43
+ } ,
33
44
} ) ;
34
45
35
46
const columns = await callTsProxy ( `
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ class ClickhouseConnector extends AdminForthBaseConnector implements IAdminForth
108
108
field . _underlineType = baseType ;
109
109
field . _baseTypeDebug = baseType ;
110
110
field . required = row . notnull == 1 ;
111
- field . primaryKey = row . pk == 1 ;
111
+ field . primaryKey = row . is_in_primary_key == 1 ;
112
112
field . default = row . dflt_value ;
113
113
fieldTypes [ row . name ] = field
114
114
} ) ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
56
56
57
57
async getAllColumnsInTable ( collectionName : string ) : Promise < Array < string > > {
58
58
59
- const sampleDocs = await this . client . db ( ) . collection ( collectionName ) . find ( { } ) . limit ( 100 ) . toArray ( ) ;
59
+ const sampleDocs = await this . client . db ( ) . collection ( collectionName ) . find ( { } ) . sort ( { _id : - 1 } ) . limit ( 100 ) . toArray ( ) ;
60
60
61
61
const fieldSet = new Set < string > ( ) ;
62
62
You can’t perform that action at this time.
0 commit comments