是否有某种类型的find_by_sql等效于mongoid,你传递一个mongo查询并从结果中实现Mongoid :: Document s?
Mongoid包装Collection对象以返回适当类的对象.
所以,如果User是Mongoid模型:
cursor = User.collection.find({}, {}) # Just like the Ruby driver... records = cursor.to_a # An array of User objects
编辑添加:它实际上也包装了Mongo的Cursor类.看这里:
def each @cursor.each do |document| yield Mongoid::Factory.build(@klass, document) end end