server: fix post creation

This commit is contained in:
Max Leiter 2022-03-28 12:28:07 -07:00
parent e0b0102603
commit 333e3647e0
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA

View file

@ -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) {