質問

I am trying to make the following mongodb query on powershell:

collection.find({"field1":"valueA","field2":"valueB","field3":/subStr_ValueC/})

I tried to do the following but doesn't work:

$query = @{
            "field1" = $notification["A"]
            "field2" = $notification["B"]
            "field3" = "/" + $notification["C"] + "/"
        }

$cursor = $collection.find([MongoDB.Driver.QueryDocument]$query)

Any idea, how to do this?

thank you very much

役に立ちましたか?

解決

Give this a try:

$query = @{
  'field1' = $notification['A']
  'field2' = $notification['B']
  'field3' = @{ '$regex' = '.*' + $notification['C'] + '.*'; '$options' = 'i' }
}

$cursor = $collection.find([MongoDB.Driver.QueryDocument]$query)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top