2014-02-27 28 views
0

指定要返回的多個字段的正確語法是什麼?指定多個字段 - RMongoDB

當指定一個字段,我沒有回我的光標結果的任何問題:

#Field specifications 
fields <- mongo.bson.from.list(list(text = 1L)) 

我已經嘗試了多種方案供指定多個領域,但我似乎無法找到正確的語法。下面是一個例子:

#Field specifications 
fields <- mongo.bson.from.list(list(_id = 0L, text = 1L, name = 1L)) 

我試着做了規範中查找聲明,以及:

cursor <- mongo.find(mongo, "twitter.test", query, 
        fields = list(_id = 0L, text = 1L, name = 1L), 
        sort = count_sort, 
        limit = 1L) 

這似乎是一個簡單的問題,但我不能讓我期待的結果。任何幫助將不勝感激!

+0

我忽視了一些項目,而瀏覽答案。我在這裏找到了我的問題的解決方案: https://gist.github.com/Btibert3/7751989 – User

回答

0

似乎所有你需要的是:

fields <- mongo.bson.from.list(c(list(_id = 0L), list(text = 1L), list(name = 1L)))