perf(server): opmitize updates table

This commit is contained in:
forehalo
2023-10-24 17:33:24 +08:00
parent fd6536ea90
commit ef1228dcb4
3 changed files with 19 additions and 7 deletions

View File

@@ -264,15 +264,15 @@ export class DocManager
* get pending updates
*/
async getUpdates(workspaceId: string, guid: string) {
return this.db.update.findMany({
const updates = await this.db.update.findMany({
where: {
workspaceId,
id: guid,
},
orderBy: {
seq: 'asc',
},
});
// perf(memory): avoid sorting in db
return updates.sort((a, b) => (a.createdAt < b.createdAt ? -1 : 1));
}
/**