-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Duplicate items in array when $push #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Not at this moment. But you could use a raw expression: https://github.com/jenssegers/Laravel-MongoDB#raw-expressions |
I have sent a pull request with that functionality. |
The problem I have with these methods is that it deviates a lot from the original Eloquent functionality. MongoDB specific functionality is always available through raw expressions. I'll leave this open for opinions from other users for now. I would rather add a third |
Yes! Good idea. Anyway.. Raw update: $data = array('foo' => 'bar', 'foo2' => 'bar2');
$id = '52ae0bf538d34983168b4571';
Post::raw(function($collection) use ($data, $id)
{
return $collection->update(array('_id' => new MongoID($id) ), array('$addToSet' => array( 'stars' => $data ) ) );
}); |
Hi jens!
Any option to prevent duplicate objects in array?
In mongo is $addToSet..
http://docs.mongodb.org/manual/reference/operator/update/addToSet/
Thanks!
The text was updated successfully, but these errors were encountered: