2012-03-04 48 views

回答

1

你不能在MongoDB中的一個請求中做到這一點。沒有加入系統。你需要做兩個請求。

# Get all user_id doing some Post 
user_ids = Post.all.only(:user_id).distinct(:user_id) 

# Get all user with this list of user_id 
User.where(:id => user_ids) 
+0

非常感謝你 – 2012-03-05 08:50:30

+0

也加了upvote :( – shingara 2012-03-05 09:03:43

相關問題