EventsDB: enable fts conditionally based on DATABASE_URL

This commit is contained in:
Alex Gleason 2024-05-16 15:48:22 -05:00
parent 00d4bf2344
commit baa6986880
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 10 additions and 1 deletions

View File

@ -42,8 +42,17 @@ class EventsDB implements NStore {
};
constructor(private kysely: Kysely<DittoTables>) {
let fts: 'sqlite' | 'postgres' | undefined;
if (Conf.databaseUrl.protocol === 'sqlite:') {
fts = 'sqlite';
}
if (['postgres:', 'postgresql:'].includes(Conf.databaseUrl.protocol!)) {
fts = 'postgres';
}
this.store = new NDatabase(kysely, {
fts5: Conf.databaseUrl.protocol === 'sqlite:',
fts,
indexTags: EventsDB.indexTags,
searchText: EventsDB.searchText,
});