Skip to content

Commit

Permalink
fix(mongo): fix database.getAssignedChannels, fix #175 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish authored Mar 22, 2021
1 parent e157a55 commit cd23bc7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/plugin-mongo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ Database.extend(MongoDatabase, {
},

async getAssignedChannels(fields, assignMap = this.app.getSelfIds()) {
const project = { pid: 1, type: 1, ...projection(fields) }
const channels = await this.channel.find({
$or: Object.entries(assignMap).map<any>(([type, ids]) => ({ type, assignee: { $in: ids } })),
}).project(projection(fields)).toArray()
}).project(project).toArray()
return channels.map(channel => ({ ...pick(Channel.create(channel.type, channel.pid), fields), ...channel, id: `${channel.type}:${channel.pid}` }))
},

Expand Down

0 comments on commit cd23bc7

Please sign in to comment.