@@ -5,6 +5,7 @@ import type { CliArgs, DbDetails, DbType } from '../types.js'
5
5
6
6
type DbChoice = {
7
7
dbConnectionPrefix : `${string } /`
8
+ dbConnectionSuffix ?: string
8
9
title : string
9
10
value : DbType
10
11
}
@@ -20,6 +21,12 @@ const dbChoiceRecord: Record<DbType, DbChoice> = {
20
21
title : 'PostgreSQL (beta)' ,
21
22
value : 'postgres' ,
22
23
} ,
24
+ sqlite : {
25
+ dbConnectionPrefix : 'file:./' ,
26
+ dbConnectionSuffix : '.db' ,
27
+ title : 'SQLite (beta)' ,
28
+ value : 'sqlite' ,
29
+ } ,
23
30
}
24
31
25
32
export async function selectDb ( args : CliArgs , projectName : string ) : Promise < DbDetails > {
@@ -37,10 +44,10 @@ export async function selectDb(args: CliArgs, projectName: string): Promise<DbDe
37
44
dbType = await p . select < { label : string ; value : DbType } [ ] , DbType > ( {
38
45
initialValue : 'mongodb' ,
39
46
message : `Select a database` ,
40
- options : [
41
- { label : 'MongoDB' , value : 'mongodb' } ,
42
- { label : 'Postgres' , value : 'postgres' } ,
43
- ] ,
47
+ options : Object . values ( dbChoiceRecord ) . map ( ( dbChoice ) => ( {
48
+ label : dbChoice . title ,
49
+ value : dbChoice . value ,
50
+ } ) ) ,
44
51
} )
45
52
if ( p . isCancel ( dbType ) ) process . exit ( 0 )
46
53
}
@@ -50,7 +57,7 @@ export async function selectDb(args: CliArgs, projectName: string): Promise<DbDe
50
57
let dbUri : string | symbol | undefined = undefined
51
58
const initialDbUri = `${ dbChoice . dbConnectionPrefix } ${
52
59
projectName === '.' ? `payload-${ getRandomDigitSuffix ( ) } ` : slugify ( projectName )
53
- } `
60
+ } ${ dbChoice . dbConnectionSuffix || '' } `
54
61
55
62
if ( args [ '--db-accept-recommended' ] ) {
56
63
dbUri = initialDbUri
0 commit comments