0
我在Mongoid下面的文档结构:SQL到MongoDB的使用Rails + Mongoid
class Post
include Mongoid::Document
field "title", type: String
field "body", type: String
field "category_name", type: String
field "category_id", type: Integer
end
,我需要选择职位的所有现有类别进行搜索。如果这是SQL,我会:
SELECT distinct category_name, category_id FROM posts
我怎么会在Mongoid的SQL查询中做到这一点?