Add methods to models for archived entities

This commit is contained in:
John R. Supplee 2021-01-11 18:18:26 +02:00
parent 01bd94d2b3
commit bbcb236a46
5 changed files with 115 additions and 44 deletions

View file

@ -1208,6 +1208,26 @@ function boardRemover(userId, doc) {
);
}
Boards.userBoards = (userId, includeArchived = false, selector = {}) => {
if (!includeArchived) {
selector = {
archived: false,
};
}
selector.$or = [
{ permission: 'public' },
{ members: { $elemMatch: { userId, isActive: true } } },
];
return Boards.find(selector);
};
Boards.userBoardIds = (userId, includeArchived = false, selector = {}) => {
return Boards.userBoards(userId, includeArchived, selector).map(board => {
return board._id;
});
};
if (Meteor.isServer) {
Boards.allow({
insert: Meteor.userId,