Closed
Description
I have a collection called "Contracts" with a field called "projects", which is an array of documents. Each document in the array would have an _id (a MongoID) and a 'projectName' (a string). I'm attempting to use the "push" function to append this array, but I cannot figure out how to add documents.
$projectId = new MongoId();
$test = DB::collection('Contracts')
->where('_id', $contractId)
->push('projects', array( '{ _id : '.$projectId.', projectName : <Project> }'));
The above code doesn't work, and I'm not sure how to do exactly what I'm trying to do. In addition, where I'm concatenating the $projectId, I really want that to be a new ObjectId.
How could I do this?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels