mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: dedupe uids before inc op
This commit is contained in:
1 file changed
+1
-1
@@ -299,7 +299,7 @@ class UserModel {
|
||||
|
||||
@ArgMethod
|
||||
static async inc(_id: number | number[], field: string, n: number = 1) {
|
||||
const ids = (Array.isArray(_id) ? _id : [_id]).filter((i) => i >= -999);
|
||||
const ids = (Array.isArray(_id) ? Array.from(new Set(_id)) : [_id]).filter((i) => i >= -999);
|
||||
if (!ids.length) return null;
|
||||
const udocs = await coll.find({ _id: { $in: ids } }).toArray();
|
||||
if (udocs.length !== ids.length) throw new UserNotFoundError(_id);
|
||||
|
||||
Reference in new issue
Block a user