I'd like to run this from my application:
db.values.updateMany( { entity_id: 123 }, { $rename: { "oldname": "newname" } } )
I've tried multiple functions like raw() and a direct statement with statement() on the connection \DB::connection('mongodb') but everything is producing errors like Call to a member function prepare() on null.
How can I run this?
You may use something like this to rename
DB::connection('mongodb')->collection('values')->update([
{ entity_id: 123 },
'$rename'=>['oldname'=> "newname"],
]);
See here for more details.
Thank you @pi0! The working result:
\DB::connection('mongodb')->collection('values')->where('entity_id',123)->update([
'$rename' => ['oldname' => 'newname']
]);
Most helpful comment
Thank you @pi0! The working result: