Skip to content

Commit f983c5e

Browse files
committed
fix: add deterministic sort to findExpiredStatuses query
1 parent 895cf82 commit f983c5e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/models/src/models/Users.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,10 @@ export class UsersRaw extends BaseRaw<IUser, DefaultFields<IUser>> implements IU
10981098
}
10991099

11001100
findExpiredStatuses(limit: number) {
1101-
return this.find<Pick<IUser, '_id'>>({ statusExpiresAt: { $lt: new Date() } }, { projection: { _id: 1 }, limit });
1101+
return this.find<Pick<IUser, '_id'>>(
1102+
{ statusExpiresAt: { $lt: new Date() } },
1103+
{ projection: { _id: 1 }, sort: { statusExpiresAt: 1 }, limit },
1104+
);
11021105
}
11031106

11041107
updatePresenceAndStatus(userId: IUser['_id'], values: Record<string, unknown>, clear?: string[]) {

0 commit comments

Comments
 (0)