I would like to pop one item from the array, and get that element.
Is it possible in mongodb?
I didn't find such information at
http://docs.mongodb.org/manual/reference/operator/pop/
This is not possible. MongoDB does not return any part of the document you previously had using a normal update, that being said it can return the full document, not just that popped element on findAndModify
( http://docs.mongodb.org/manual/reference/command/findAndModify/ ), you could then filter that element out, either the first or the last.
NB: I should warn that findAndModify is basically like picking out every document in the query and operating on it, that's how it is able to return it so you might see some performance loss on queries that span a large nummber.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With