mirror of
https://github.com/thelounge/thelounge
synced 2024-11-15 00:37:13 +00:00
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:
parent
89ee537364
commit
cc3302e874
1 changed files with 15 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue