我有一个带有 embedsMany 模型评论的模型新闻,并且在模型评论中我有 embedsMany 模型回复
当我这样做时:
$new = News::create(["title"=>"Simple new", "body"=>"this is a simple news"]);
$comment = $new->comments()->create(["subject"=>"comment 1", "body"=>"my comment"]);
插入正常,数据库中的数据为:
{
"title" : "Simple new",
"body" : "this is a simple news",
"_id" : ObjectId("5569b157bed33066220041ac"),
"comments" : [
{
"subject" : "comment 1",
"body" : "my comment",
"_id" : ObjectId("5569cc28bed330693eb7acd9")
}
]
}
但是当我这样做时:
$reply = $comment->replies()->create(["subject"=>"reply to comment 1", "body"=>"my reply"]);
数据库是:
{
"title" : "Simple new",
"body" : "this is a simple news",
"_id" : ObjectId("5569b157bed33066220041ac"),
"comments" : [
{
"subject" : "comment 1",
"body" : "my comment",
"_id" : ObjectId("5569cc28bed330693eb7acd9"),
"replies" : {
"0" : {
"subject" : "reply to comment 1",
"body" : "my reply",
"_id" : ObjectId("5569cc33bed330693eb7acda"
}
}
}
]
}
并且删除回复不起作用