SOLUTION:
$tagCollection = $db["tag"]
$query = @{
'$where' = "'star wars episode VII'.search(this['name']) >= 0;"
}
$cursor = $tagCollection.find([MongoDB.Driver.QueryDocument]$query)
题
I am trying to write the following mongodb shell command in powershell:
db.tag.find({$where:"'star wars episode VII'.search(this.name) >= 0"})
So far what I have done is:
$tagCollection = $db["tag"]
$query = @{
"name" = @{ '$where' = "'star wars episode VII'.search(this['name']) >= 0;" }
}
$cursor = $tagCollection.find([MongoDB.Driver.QueryDocument]$query)
But I'm getting the following error
Exception has been thrown by the target of an invocation.
+ CategoryInfo : NotSpecified: (:) [], TargetInvocationException
+ FullyQualifiedErrorId : System.Reflection.TargetInvocationException
Any idea/recommendation about what is wrong would be high appreciated
解决方案
SOLUTION:
$tagCollection = $db["tag"]
$query = @{
'$where' = "'star wars episode VII'.search(this['name']) >= 0;"
}
$cursor = $tagCollection.find([MongoDB.Driver.QueryDocument]$query)