Created
March 20, 2015 08:08
-
-
Save anicet/47bf383a554a76eb7e1c to your computer and use it in GitHub Desktop.
Mongoid map reduce find duplicate email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map = %Q{function() { emit(this.email, 1); }} | |
reduce = %Q{function(k, v) {return Array.sum(v);}} | |
User.all.map_reduce(map, reduce).out(inline: true).map{|u| | |
u["_id"] if u["value"] != 1.0 | |
}.compact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment