sqlite: create serialize_fetchall helper function

That puts all the serialization logic into one place and
allows us to use async / promises
This commit is contained in:
Reto Brunner 2022-08-27 14:21:29 +02:00 committed by Reto Brunner
parent 89ee537364
commit cc3302e874

View File

@ -279,6 +279,21 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
}); });
}); });
} }
private serialize_fetchall(stmt: string, ...params: any[]): Promise<any> {
return new Promise((resolve, reject) => {
this.database.serialize(() => {
this.database.all(stmt, params, (err, rows) => {
if (err) {
reject(err);
return;
}
resolve(rows);
});
});
});
}
} }
// TODO: type any // TODO: type any