core: 支持联合排名

This commit is contained in:
undefined committed 2021-06-19 17:26:34 +08:00
1 parent c0e67917a2
commit f906178de3
5 files changed
+70 -42

No files matched your search

+16
View File
@@ -10,6 +10,7 @@ import UserModel, { deleteUserCache } from './user';
const coll = db.collection('domain');
const collUser = db.collection('domain.user');
const collUnion = db.collection('domain.union');
interface DomainUserArg {
_id: number,
@@ -256,6 +257,21 @@ class DomainModel {
await collUser.deleteMany({ domainId });
await bus.parallel('domain/delete', domainId);
}
@ArgMethod
static async addUnion(domainId: string, union: string[]) {
return await collUnion.updateOne({ _id: domainId }, { $set: { union } }, { upsert: true });
}
@ArgMethod
static async removeUnion(domainId: string) {
return await collUnion.deleteOne({ _id: domainId });
}
@ArgMethod
static async getUnion(domainId: string) {
return await collUnion.findOne({ _id: domainId });
}
}
export default DomainModel;