[英]How to pass a list in mongo db query
This works when I am dynamically querying by just one particular value of col but incase my col is an array eg: c("red","blue"), it is failing. 当我仅通过col的一个特定值进行动态查询时,如果我的col是一个数组,例如c(“ red”,“ blue”),则此方法会失败。
col<-"red"
pipe1 <- paste("{\"$match\":{\"color\":\"",col,"\"}}", sep = "")
query1 <- list(
mongo.bson.from.JSON(pipe1),
mongo.bson.from.JSON('
{
"$project" : {
"_id" : 0,
"Email":"$email",
"color":"$color" }
}'))
Any solutions? 有什么办法吗? Using this to convert Json to dataframe in R
使用此将Json转换为R中的数据帧
If col
is an array, like you say, then the string it produces wouldn't be valid JSON. 如果
col
是一个数组,如您所说,那么它生成的字符串将不是有效的JSON。 I think it would be something like: 我认为应该是这样的:
{"$match":{"color": "red", "blue" }}
When what you need is: 当您需要的是:
{"$match":{"color": ["red", "blue"] }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.