sqlite: use serialize_fetchall in search
This commit is contained in:
parent
ee8223c200
commit
5e1cbe32f9
@ -195,10 +195,10 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
|
|||||||
}) as Message[];
|
}) as Message[];
|
||||||
}
|
}
|
||||||
|
|
||||||
search(query: SearchQuery): Promise<SearchResponse> {
|
async search(query: SearchQuery): Promise<SearchResponse> {
|
||||||
if (!this.isEnabled) {
|
if (!this.isEnabled) {
|
||||||
// this should never be hit as messageProvider is checked in client.search()
|
// this should never be hit as messageProvider is checked in client.search()
|
||||||
return Promise.reject(
|
throw new Error(
|
||||||
"search called but sqlite provider not enabled. This is a programming error"
|
"search called but sqlite provider not enabled. This is a programming error"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -227,22 +227,16 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
|
|||||||
query.offset = parseInt(query.offset as string, 10) || 0;
|
query.offset = parseInt(query.offset as string, 10) || 0;
|
||||||
params.push(String(query.offset));
|
params.push(String(query.offset));
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
const rows = await this.serialize_fetchall(select, ...params);
|
||||||
this.database.all(select, params, (err, rows) => {
|
const response: SearchResponse = {
|
||||||
if (err) {
|
searchTerm: query.searchTerm,
|
||||||
reject(err);
|
target: query.channelName,
|
||||||
} else {
|
networkUuid: query.networkUuid,
|
||||||
const response: SearchResponse = {
|
offset: query.offset as number,
|
||||||
searchTerm: query.searchTerm,
|
results: parseSearchRowsToMessages(query.offset as number, rows).reverse(),
|
||||||
target: query.channelName,
|
};
|
||||||
networkUuid: query.networkUuid,
|
|
||||||
offset: query.offset as number,
|
return response;
|
||||||
results: parseSearchRowsToMessages(query.offset as number, rows).reverse(),
|
|
||||||
};
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canProvideMessages() {
|
canProvideMessages() {
|
||||||
|
Loading…
Reference in New Issue
Block a user