Re: Remove nested document with condition

29 views
Skip to first unread message

Ronald Stalder

unread,
Nov 15, 2012, 1:59:02 PM11/15/12
to mongod...@googlegroups.com
I can think of two possibillities:

(a) find all the documents with dogs, for each document found loop the pets to find the lowest dog, then remove it:

(b) use aggregate or mapReduce to find the lowest dogs per _id and remove it

You can find an analog expample (for node.js) on https://gist.github.com/4080463 (the mapReduce (2nd file) actually doesnt remove the lowest score but you can add this to the finalize function

cheers


Ronald Stalder

unread,
Nov 15, 2012, 2:02:10 PM11/15/12
to mongod...@googlegroups.com
SORRY,

add remove to the finalize function does not work, that was stupid of me. You'll have to loop the resulting collection of the mapReduce

Reply all
Reply to author
Forward
0 new messages