Thursday, April 21, 2011

Removing an object in a child collection in MongoDB

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.

From stackoverflow

0 comments:

Post a Comment