如何查询字段并返回Projex Orb的数据集?

问题描述:

我试图找到所有reasons对象与type_id = 3如何查询字段并返回Projex Orb的数据集?

用ActiveRecord,我希望查询为:

reasons = Reason.where('type_id = 3') 

那么我可以遍历每个原因有:

reasons.each do |reason| 
    # do stuff with the reason... 
end 

对于更简单的查询,可以使用支持缩短语法的新过滤器选项:

reasons = Reason.all().filter(type_id=3) 
for reason in reasons: 
    # do stuff with reason 

对于更高级的查询,您可以使用查询语法:

from orb import Query as Q 
reasons = Reason.select(where=Q('type_id') == 3) 
for reason in reasons: 
    # do stuff with reason