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")
|
||||
.toString(),
|
||||
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()
|
||||
return newFile
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(
|
||||
newFiles.map((file) => {
|
||||
newPost.$add("files", file.id)
|
||||
newFiles.map(async (file) => {
|
||||
await newPost.$add("files", file.id)
|
||||
await newPost.save()
|
||||
})
|
||||
)
|
||||
await newPost.save()
|
||||
|
||||
res.json(newPost)
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue