Datamapper中是否存在ActiveRecord的find_by_方法的模拟
例如:@user = User.find_by_email(params[:email])
答案 0 :(得分:2)
根据datamapper documentation和我的方式,您可以这样做:
@user = User.first(:email => params[email]) #strictly the same as find_by_email in Activerecord
@user = User.all(:email => params[email]) #strictly the same as find_all_by_email in Activerecord
@user = User.last(:email => params[email]) #no real equivalent in Active Record