B4J Question AND in MongoDB

Hanz

Active Member
Hello,

I am trying to query a record from a collection, "employees". The query is to find a record which _id is 1 and the name is Dev. I used the statement below:

Dim emplist3 As List = employees.Find(CreateMap("$and" : CreateMap("_id":1, "name":"Dev")),Null,Null)

But it says something that the $and must be an array. Thus, I used the statement below:

Dim emplist3 As List = employees.Find(Array(CreateMap("$and" : CreateMap("_id":1, "name":"Dev"))),Null,Null)

But the above generates an error which says something like,
Dim emplist3 As List = employees.Find(Array(Crea
javac 1.8.0_152
src\b4j\example\main.java:100: error: incompatible types: Object[] cannot be converted to Map

What is wrong with the above codes?
 
Top