From 802c24dde53b9d4ca3c7607e0333a21cfc3f2485 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 4 Jul 2018 23:32:05 +0800 Subject: [PATCH] compatible with v2 --- routes/get.js | 2 +- routes/post.js | 2 +- utils/mongodb.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/get.js b/routes/get.js index 5c36128..82429d9 100644 --- a/routes/get.js +++ b/routes/get.js @@ -18,7 +18,7 @@ module.exports = async (ctx) => { } ctx.response.set('X-Koa-Redis', 'true'); } else { - data = await ctx.mongodb.find({ id }) || []; + data = await ctx.mongodb.find({ player: id }) || []; ctx.redis.set(`danmaku${id}`, JSON.stringify(data)); if (limit) { data = data.slice(-1 * parseInt(limit)); diff --git a/routes/post.js b/routes/post.js index facd146..8f589ec 100644 --- a/routes/post.js +++ b/routes/post.js @@ -4,7 +4,7 @@ module.exports = async (ctx) => { const body = ctx.request.body; const dan = new ctx.mongodb({ - id: body.id, + player: body.id, author: body.author, time: body.time, text: body.text, diff --git a/utils/mongodb.js b/utils/mongodb.js index 2c43056..3037c3f 100644 --- a/utils/mongodb.js +++ b/utils/mongodb.js @@ -13,7 +13,7 @@ db.once('open', () => { }); const danmakuSchema = new mongoose.Schema({ - id: { + player: { type: String, index: true, },