使用带有ruby的datamapper。假设我有一个名为Post的模型:
class Post
include DataMapper::Resource
property :id, Serial
property :name, String, length: 255
property :category_ids, Object
end
Post.create(name: 'My post', category_ids: [1,2,3])
Post.all(category_ids: [1])
=> []
Post.all(category_ids: [1,2,3])
=> []
可以查询对象属性吗?
答案 0 :(得分:0)
使用Range
。 Post.all(category_ids: (1..3))