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";
22import { toTitleCase } from '../utils.js' ;
33import { generateResourceFile } from "./generateResourceFile.js" ;
44import { injectResourceIntoIndex } from "./injectResourceIntoIndex.js" ;
5- import { select } from "@inquirer/prompts" ;
5+ import { search , Separator } from "@inquirer/prompts" ;
66
77export default async function createResource ( args ) {
88 console . log ( "Bundling admin SPA..." ) ;
@@ -27,9 +27,20 @@ export default async function createResource(args) {
2727 } ) )
2828 ) ;
2929
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+ } ,
3344 } ) ;
3445
3546 const columns = await callTsProxy ( `
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ class ClickhouseConnector extends AdminForthBaseConnector implements IAdminForth
108108 field . _underlineType = baseType ;
109109 field . _baseTypeDebug = baseType ;
110110 field . required = row . notnull == 1 ;
111- field . primaryKey = row . pk == 1 ;
111+ field . primaryKey = row . is_in_primary_key == 1 ;
112112 field . default = row . dflt_value ;
113113 fieldTypes [ row . name ] = field
114114 } ) ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataS
5656
5757 async getAllColumnsInTable ( collectionName : string ) : Promise < Array < string > > {
5858
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 ( ) ;
6060
6161 const fieldSet = new Set < string > ( ) ;
6262
You can’t perform that action at this time.
0 commit comments