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
@ -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 New Issue
Block a user