Skip to content

Commit

Permalink
fix(teach): mongodb field implementation (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 18, 2020
1 parent 185c7e1 commit 418b4d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-teach/src/database/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ declare module 'koishi-core/dist/context' {
extendDatabase<typeof MongoDatabase>('koishi-plugin-mongo', {
async getDialoguesById(ids, fields) {
if (!ids.length) return []
const p = {}
for (const field of fields) p[field] = 1
const dialogues = await this.db.collection('dialogue').find({ _id: { $in: ids } }).project(p).toArray()
let cursor = this.db.collection('dialogue').find({ _id: { $in: ids } })
if (fields) cursor = cursor.project(Object.fromEntries(fields.map(k => [k, 1])))
const dialogues = await cursor.toArray()
dialogues.forEach(d => {
d._id = d.id
defineProperty(d, '_backup', clone(d))
Expand Down

0 comments on commit 418b4d1

Please sign in to comment.