You can use $pull
to remove 53725f9d186f521d07d63af1
:
$collection->update(
array('_id' => new MongoId('537267b7186f521c07d63af1')), // _id of the document
array('$pull' =>
array('users' => new MongoId('53725f9d186f521d07d63af1') // id to be removed
)
);
And $addToSet
to add a new id:
$collection->update(
array('_id' => new MongoId('537267b7186f521c07d63af1')), // _id of the document
array('$addToSet' =>
array('users' => new MongoId('51725f9d186f521d07d33ah1') // id to be added
)
);