refactor(api): get new reply id from save() call
This commit is contained in:
parent
489b2e0558
commit
7f1f8a72f5
@ -36,10 +36,18 @@ export default eventHandler(async (ev) => {
|
||||
whichChapter: replyingTo.whichChapter,
|
||||
datePosted: new Date(),
|
||||
});
|
||||
let nrs = await newReply.save();
|
||||
const { _id } = await newReply.save();
|
||||
const nrs = (await Review.findOne({ _id })
|
||||
.populate("author", "username _id blocked")
|
||||
.exec())!;
|
||||
replyingTo.replies.push(nrs._id);
|
||||
await replyingTo.save();
|
||||
const story = await Story.findById(replyingTo.leftOn);
|
||||
if (!story) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
});
|
||||
}
|
||||
return {
|
||||
back: `/story/${replyingTo.leftOn}/${
|
||||
story!.chapters.findIndex((x) => x.id === nrs.whichChapter) + 1
|
||||
|
Loading…
Reference in New Issue
Block a user