我正在使用mongolite软件包连接并从MongoDB中检索数据。如何在mongolite查询中传递值?
如果我尝试上面的代码,会遇到以下问题。请帮助我解决。
##connecting mongodb
library(mongolite)
mongo<-mongolite::mongo(collection = "Sample", db = "Test", url =
"mongodb://User:123@Wyyuyu:13333/ty2_U",verbose = TRUE)
## getting all data from collection data from collection below query is working fine.
values <- mongo$find()
## But I want to filter specific value by passing value.
for(i in c("process","check","queue"))
{
values <- mongo$find('{"field" : i}',)
}
如果我尝试上面的代码,会遇到以下问题。请帮助我解决。
Error: Invalid JSON object: {"field" : i}