server: fix post creation
This commit is contained in:
parent
e0b0102603
commit
333e3647e0
1 changed files with 6 additions and 6 deletions
|
@ -80,20 +80,20 @@ posts.post(
|
||||||
.digest("hex")
|
.digest("hex")
|
||||||
.toString(),
|
.toString(),
|
||||||
html: html || '',
|
html: html || '',
|
||||||
|
userId: req.body.userId,
|
||||||
|
postId: newPost.id
|
||||||
})
|
})
|
||||||
|
|
||||||
await newFile.$set("user", req.body.userId)
|
|
||||||
await newFile.$set("post", newPost.id)
|
|
||||||
await newFile.save()
|
await newFile.save()
|
||||||
return newFile
|
return newFile
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
newFiles.map((file) => {
|
newFiles.map(async (file) => {
|
||||||
newPost.$add("files", file.id)
|
await newPost.$add("files", file.id)
|
||||||
|
await newPost.save()
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
await newPost.save()
|
|
||||||
|
|
||||||
res.json(newPost)
|
res.json(newPost)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue