mongoDb通过匹配来自同一索引对象数组的多个值来查找

时间:2019-01-19 00:20:52

标签: node.js mongodb

我的数据库中有此文档,例如:

{x: 10, y: 20, val: "h"}
{x: 20, y: 70, val: "ho"}
{x: 30, y: 80, val: "hol"}
{x: 40, y: 90, val: "hola"}
{x: 50, y: 29, val: "holas"}

我想通过传递一个数组来获得所有匹配x和y值的文档,例如:

[{x: 10, y 20},{x: 20, y 70}]

所以要回报我:

[{x: 10, y: 20, val: "h"},{x: 20, y: 70, val: "ho"}]

我已经尝试过这种方法,但是不起作用:

var ricerca = {
   $in: [{x: 10, y 20},{x: 20, y 70}]
};

db.collection('exampe').find(ricerca).toArray(...

1 个答案:

答案 0 :(得分:1)

您需要使用 rngNew = "D1" & ":" & Cells(lRowEnd, 4).Address Set rngShopTime = Range(rngNew) Dim txtShopFree As String txtShopFree = "=""ShopFree""" Dim rngShop As String rngShop = "C1" & ":" & Cells(lRowEnd, 3).Address(False, True) With rngShopTime .FormatConditions.Add Type:=xlExpression, Formula1:="=" & rngShop & txtShopFree .FormatConditions(1).StopIfTrue = False With .FormatConditions(.FormatConditions.Count) .SetFirstPriority With .Interior .PatternColorIndex = xlAutomatic .Color = RGB(128, 128, 128) .TintAndShade = 0 End With End With End With

$or