Laravel - Jenssegers MongoDB 嵌套数组更新不起作用

Laravel - Jenssegers MongoDB nested array update not working

有人可以指出我的代码有什么问题吗? 我正在尝试通过 Laravel Jenssegers 更新 MongoDB 中的嵌套数组。这是我的代码

 $update_status = Journal::where('_id', "5cd10b325586e9122761f675" )
    ->update(
        [], 
        [ '$set' =>
            [
                "workflow.$[i].stages.$[j].stage_code" => "edit",
                "workflow.$[i].stages.$[j].stage_name" => "Editing"
            ]
        ],
        [ 'arrayFilters' => [
                [ "i.basic_details.wfCode" => 'wf1' ],
                [ "j.stage_id" => "wf1_2" ]
            ]
        ]
    );

我的 Journal collection 是:

{
    "_id" : ObjectId("5cd10b325586e9122761f675"),
    "workflow" : [ 
        {
            "basic_details" : {
                "wfCode" : "wf1"
            },
            "stages" : [ 
                {
                    "stage_id" : "wf1_1",
                    "stage_code" : "submission",
                    "stage_name" : "Submission",
                    "button_label" : "submit"
                }, 
                {
                    "stage_id" : "wf1_2",
                    "stage_code" : "s2",
                    "stage_name" : "S2",
                    "button_label" : "label2"
                }
            ]
        }
    ]
}

执行后,我得到 $update_status 作为 1,但在查看 collection 时,它保持不变。

请检查此查询,我认为这应该有效...

$articleId = new ObjectID("5cd10b325586e9122761f675");
$result = Journal::raw(function ($collection) use ($articleId) {
return $collection->updateOne(
    array ('_id' => $articleId), 
    array ('$set' => 
        array(
            'jnl_workflow.$[i].wf_stages.$[j].wf_stage_code' => "edit",
            'jnl_workflow.$[i].wf_stages.$[j].wf_stage_name' => "Editing" 
        )
    ), 
    array( 'arrayFilters' => [ array ('i.wf_basic_details.wfCode' => 'wf1'), array('j.wf_stage_id' => "wf1_2" ) ] ) 
)

});