Is there something help me write $function operator with mongodb and php? I try some ways but it doesn’t work:
array_push($pipeline, ['$set' => ['todos' => [
'$function' => [
'body' => 'function(todos) {
return todos;
}',
'args' => ['todos'],
'lang' => 'js',
]
]]]);
==> todos array is converts to string “todo”
or
array_push($pipeline, ['$set' => ['todos' => [
'$function' => [
'body' => function($todos) {
return $todos;
},
'args' => ['todos'],
'lang' => 'js',
]
]]]);
it doesn’t work.