Give this a try:
$query = @{
'field1' = $notification['A']
'field2' = $notification['B']
'field3' = @{ '$regex' = '.*' + $notification['C'] + '.*'; '$options' = 'i' }
}
$cursor = $collection.find([MongoDB.Driver.QueryDocument]$query)
سؤال
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)