@@ -454,32 +454,18 @@ export interface IMiftahDB<T extends MiftahValue = MiftahValue> {
454
454
/*
455
455
Represents the PRAGMA statements that can be used to configure the database.
456
456
*/
457
- export type JournalModes = "DELETE" | "TRUNCATE" | "PERSIST" | "WAL" | "MEMORY" ;
458
- export type SynchronousModes = "OFF" | "NORMAL" | "FULL " | "EXTRA" ;
459
- export type TempStoreModes = "DEFAULT" | "MEMORY" | "FILE" ;
460
- export type LockingModes = "NORMAL" | "EXCLUSIVE" ;
461
- export type AutoVacuumModes = "OFF" | "FULL" | "INCREMENTAL" ;
457
+ export type DBOptions = Partial < {
458
+ [ K in keyof typeof defaultDBOptions ] : K extends "cacheSize " | "mmapSize"
459
+ ? number
460
+ : ( typeof defaultDBOptions ) [ K ] ;
461
+ } > ;
462
462
export const defaultDBOptions = {
463
- journalMode : "WAL" as JournalModes ,
464
- synchronousMode : "NORMAL" as SynchronousModes ,
465
- tempStoreMode : "MEMORY" as TempStoreModes ,
463
+ journalMode : "WAL" as "DELETE" | "TRUNCATE" | "PERSIST" | "WAL" | "MEMORY" ,
464
+ synchronousMode : "NORMAL" as "OFF" | "NORMAL" | "FULL" | "EXTRA" ,
465
+ tempStoreMode : "MEMORY" as "DEFAULT" | "MEMORY" | "FILE" ,
466
466
cacheSize : - 64000 ,
467
467
mmapSize : 30000000000 ,
468
- lockingMode : "NORMAL" as LockingModes ,
469
- autoVacuumMode : "OFF" as AutoVacuumModes ,
468
+ lockingMode : "NORMAL" as "NORMAL" | "EXCLUSIVE" ,
469
+ autoVacuumMode : "OFF" as "OFF" | "FULL" | "INCREMENTAL" ,
470
+ cleanUpOnClose : false as boolean ,
470
471
} as const ;
471
- export type DBOptions = {
472
- [ K in keyof typeof defaultDBOptions ] ?: K extends "cacheSize" | "mmapSize"
473
- ? number
474
- : K extends "journalMode"
475
- ? JournalModes
476
- : K extends "synchronousMode"
477
- ? SynchronousModes
478
- : K extends "tempStoreMode"
479
- ? TempStoreModes
480
- : K extends "lockingMode"
481
- ? LockingModes
482
- : K extends "autoVacuumMode"
483
- ? AutoVacuumModes
484
- : never ;
485
- } ;
0 commit comments