Hi
New to ArangoDb, using the PHP Driver and I'm struggling with the AQL update syntax for nested documents.
Basically an "addToSet" as with MongoDb.
Pseudo document in profiles collection
{
   '_key'   : '81855392035',
   'doc'    : 'profile',
   'name'   : 'John',
   'surname' : 'Jones',
}
I want to add the following e mail contact to a yet-to-be-created array in the above document.
$email = json_encode(array('name' => 'Peter Smith',
                                'at'   => '
pe...@nowhere.com',
                                'type'  => 'business'));
// The path to array: detail.cnx.e (using a dot syntax)
$update = "for p in profiles
                filter p.doc == @doc && p._key == @key
                update p with {detail:{'cnx':{'e': $email}}} in
                profiles";
$bindVars = array('doc'=>'profile', 'key'=> '81855392035');
Executing the statement with the above creates the email in the specified array.
The old $email is overwritten when I repeat the statement with a new $email. I would like to add it to the set.
In stackoverflow, the official documentation and here ACL functions are suggested as possible solutions like Merge/Merge_Recursive and Union.
The examples are simplistic, don't use nested documents, and to cryptic for a newbie.Â
The final ACL update might need a HAS function to check existence of the attribute. Had to create it to test a Union example.
What is the correct syntax, with the relevant functions for the $update? I had no success with different dots, commas, curly brackets, braces etc.?
Everyday I'm liking Arangodb more and more and Jan thank you for the Php driver.