开发者

Getting access to models collection in Mongoid instead of Criteria object

开发者 https://www.devze.com 2023-03-14 23:59 出处:网络
Whenever I do: Person.where(...) I get a Criteria object. That\'s understandable. But开发者_JS百科 I couldn\'t find how do I get access to actual models collection? For now, I have to do this worka

Whenever I do:

Person.where(...)

I get a Criteria object. That's understandable. But开发者_JS百科 I couldn't find how do I get access to actual models collection? For now, I have to do this workaround:

Person.where(...).map { |person| person }

And then query gets executed and I have an array of Person objects. Is there an easier method? #all doesn't seem to work, it returns the same Criteria object.


Just convert the Criteria object to an array:

Person.all.to_a
0

精彩评论

暂无评论...
验证码 换一张
取 消