Hi,
Using Ripple, I wonder what is the best way to implement a simple
find_by_email function.
Since i don't want to use the email as a key, is there another way
that using a mapreduce function ?
Many thanks,
Samuel (newbie)
require 'ripple'
require 'digest/d5'
class User
include Ripple::Document
property :email, String, :presence => true
property :hash_password, String, :presence => true
def self.find_by_email(email)
map = "
function(v) {
if (v.values) {
var val = Riak.mapValuesJson(v)[0];
return (val.email === '#{email}' ) ? v.key : null;
} else return null;
}
"
Riak::MapReduce.new(bucket.client).add(bucket).map(map,
:keep => true).run
end
def password=(pwd)
self.hash_password = Digest::MD5.hexdigest(pwd)
end
def password
self.hash_password
end
end
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com