compatible with v2

master
DIYgod 6 years ago
parent 40e172ce12
commit 802c24dde5
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
  1. 2
      routes/get.js
  2. 2
      routes/post.js
  3. 2
      utils/mongodb.js

@ -18,7 +18,7 @@ module.exports = async (ctx) => {
} }
ctx.response.set('X-Koa-Redis', 'true'); ctx.response.set('X-Koa-Redis', 'true');
} else { } else {
data = await ctx.mongodb.find({ id }) || []; data = await ctx.mongodb.find({ player: id }) || [];
ctx.redis.set(`danmaku${id}`, JSON.stringify(data)); ctx.redis.set(`danmaku${id}`, JSON.stringify(data));
if (limit) { if (limit) {
data = data.slice(-1 * parseInt(limit)); data = data.slice(-1 * parseInt(limit));

@ -4,7 +4,7 @@ module.exports = async (ctx) => {
const body = ctx.request.body; const body = ctx.request.body;
const dan = new ctx.mongodb({ const dan = new ctx.mongodb({
id: body.id, player: body.id,
author: body.author, author: body.author,
time: body.time, time: body.time,
text: body.text, text: body.text,

@ -13,7 +13,7 @@ db.once('open', () => {
}); });
const danmakuSchema = new mongoose.Schema({ const danmakuSchema = new mongoose.Schema({
id: { player: {
type: String, type: String,
index: true, index: true,
}, },

Loading…
Cancel
Save