是删除这里吗?
await Book.insertMany(arr);
ctx.body = {
code: 1,
msg: '添加成功',
data: {
addCount: arr.length,
},
};
});
router.post('/add', async (ctx) => {
const {
name,
price,
publishDate,
author,
classify,
count,
} = getBody(ctx);
const book = new Book({
name,
price,
publishDate,
author,
classify,
count,
});
const res = await book.save();
ctx.body = {
data: res,
code: 1,
msg: '添加成功',
};
});