Removing an object in a child collection in MongoDB

Posted by Jeremy B. on Stack Overflow See other posts from Stack Overflow or by Jeremy B.
Published on 2010-05-03T16:43:10Z Indexed on 2010/05/03 16:48 UTC
Read the original article Hit count: 174

Filed under:
|

I've got a collection of content. Said collection has a collection of responses as such

Content : [{ 'id' : '1234', 
    'Responses' : [{
        'id' : '12345'
    }

etc. Now, I want to remove response 12345, but I don't want to remove all of the responses. I can't seem to find the command to do so. I'm getting the impression that the correct action is to grab the object, rebuild the Responses without the one I want removed, and then save the Content object as a whole. Provided there are many responses, this seems like a bad practice to have to load the entire object that way.

© Stack Overflow or respective owner

Related posts about mongodb

Related posts about delete