开发者

Getting access to models collection in Mongoid instead of Criteria object

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜