Find duplicate documents in mongoid with map/reduce
map = %Q{
function() {
emit(this.email, 1);
}
}
reduce = %Q{
function(key, values) {
return Array.sum(values);
}
}
User.all.map_reduce(map, reduce).out(inline: true).each do |u|
p u["_id"] if u["value"] != 1
end
Written by Javier Cervantes
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#