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, },