简体   繁体   English

Haskell MongoDB查询中如何使用“ $ and”运算符

[英]How to use “$and” operator in Haskell MongoDB query

I am trying to use "$and" operator in Haskell mongoDB which is not working: 我试图在Haskell mongoDB中使用“ $ and”运算符,该运算符不起作用:

myFilter = do
   cursor <- MongoDB.find (MongoDB.select ["$and" =: [["field1" =: "test1"], ["field2" =: "test2"], ["field3" =: "test3"]]],  "db") 
   rest cursor

Thanks in advance. 提前致谢。

You have an unnecessary comma before "db" which is causing a type error. 您在“ db”之前有一个不必要的逗号,这会导致类型错误。

Try this: 尝试这个:

myFilter = do
   cursor <- MongoDB.find (MongoDB.select ["$and" =: [["field1" =: "test1"], ["field2" =: "test2"], ["field3" =: "test3"]]]  "db")
   rest cursor

Note: 注意:

  • you don't really need to use "$and" because it is the default. 您实际上不需要使用“ $ and”,因为它是默认值。
  • where you specify "db" is the name of a collection. 您在其中指定“ db”的名称是集合的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM