好友:寻宝关系加成及黑名单屏蔽

This commit is contained in:
luying
2021-02-05 11:29:38 +08:00
parent f48be637af
commit 871e71ab54
8 changed files with 113 additions and 10 deletions
+10 -1
View File
@@ -56,7 +56,9 @@ export default class FriendRelation extends BaseModel {
document.populate('friends.friendShip', null, 'FriendShip');
}
let result: FriendRelationType = await document;
let result: FriendRelationType = await document.lean({ getters: true, virtuals: true });;
console.log(JSON.stringify(result));
return result;
}
@@ -79,6 +81,13 @@ export default class FriendRelation extends BaseModel {
return result
}
public static async isInBlackList(roleId: string, hisRoleId: string) {
let result = await FriendRelationModel.find({
$or: [{ roleId, 'blacklist.roleId': hisRoleId}, { hisRoleId, 'blacklist.roleId': roleId}]
}).lean();
return result.length > 0;
}
public static async deleteAccount(roleId: string) {
let result = await FriendRelationModel.deleteMany({ roleId });
await FriendRelationModel.updateMany({}, { $pull: { friends: { roleId }, blacklist: { roleId } }});