lumen mongodb:如何更新组中的记录

我的代码如下,

foreach ($getEmails as $emails) {
                $update =[];
                if (isset($emails["suite_id"]) && $emails["suite_id"]) {
                    $emailSuiteId = explode(",", $emails["suite_id"]);
                    $update["suite_id"]= implode(",", array_unique(array_merge($emailSuiteId, $suiteIds)));
                }                 
                $update["updated_at"] = new \DateTime();
                $update["updated_by"] = $request->user_id;
                DB::connection('mongodb')->collection('email_message')
                ->Where('aid', (int)$emails['aid'])
                ->Where('email_account_id', (int)$request->email_account_id)->update($update);
            }

有没有办法在单个查询中更新记录而不是在循环中更新记录?

请尽快给我回复 . 谢谢 .

回答(0)