0
我試圖找到所有reasons
對象與type_id = 3
:如何查詢字段並返回Projex Orb的數據集?
用ActiveRecord,我希望查詢爲:
reasons = Reason.where('type_id = 3')
那麼我可以遍歷每個原因有:
reasons.each do |reason|
# do stuff with the reason...
end
我試圖找到所有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