title: How to run a query with Boolean property check
body: <p><strong>Folder documents:</strong></p>
  
  <pre><code>{"_id":"5d1e2da512ad38225af60869","id":1,"name":"inbox","must":true}
  {"_id":"5d1e2da512ad38225af6086b","id":2,"name":"outbox","must":true}
  {"_id":"5d1e2da512ad38225af6086d","id":3,"name":"drafts","must":true}
  {"_id":"5d1e2da512ad38225af6086f","id":4,"name":"trash","must":true}
  </code></pre>
  
  <p><strong>Mail documents:</strong></p>
  
  <pre><code>{"_id":"5d1e2da512ad38225af60871","id":1,"isdeleted":true,"foldersids":[1],"subject":"Hello1","body":"Hello this is mail 1"}
  {"_id":"5d1e2da512ad38225af60873","id":2,"isdeleted":false,"foldersids":[1],"subject":"Hello2","body":"Hello this is mail 2"}
  </code></pre>
  
  <p>I'm trying to get all the mails that are not marked as deleted, and get their Id value only, which is a separate field (not object_id field)</p>
  
  <p>In my database I have 2 documents - 1 marked as deleted and 1 marked as not deleted. This code always returns both of the documents although the expected result is that it returns only the I'd of the one that is not deleted. What could cause it to fail? </p>
  
  <p>Edit: Complete example</p>
  
  <p><strong>My golang code</strong>:</p>
  
  <p><strong>Folder.go</strong></p>
  
  <pre><code>package main
  
  type Folder struct {
      Id int
      Name string
      Must bool
  }
  </code></pre>
  
  <p><strong>Mail.go</strong></p>
  
  <pre><code>package main
  
  type Mail struct{
      Id int
      IsDeleted bool
      FoldersIds []int
      Subject string
      Body string
  }
  </code></pre>
  
  <p><strong>main.go</strong></p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "github.com/globalsign/mgo"
      "github.com/globalsign/mgo/bson"
  )
  
  func main(){
      inbox := Folder{
          Id:1,
          Name:"inbox",
          Must:true,
      }
      outbox := Folder{
          Id:2,
          Name:"outbox",
          Must:true,
      }
      drafts := Folder{
          Id:3,
          Name:"drafts",
          Must:true,
      }
      trash := Folder{
          Id:4,
          Name:"trash",
          Must:true,
      }
  
      session, _ := mgo.Dial("localhost:27017")
  
      session.DB("Outlook").C("Folders").Upsert(bson.M{"id": inbox.Id}, inbox)
      session.DB("Outlook").C("Folders").Upsert(bson.M{"id": outbox.Id}, outbox)
      session.DB("Outlook").C("Folders").Upsert(bson.M{"id": drafts.Id}, drafts)
      session.DB("Outlook").C("Folders").Upsert(bson.M{"id": trash.Id}, trash)
  
      mail1 := Mail{Id:1,Body:"Hello this is mail 1", FoldersIds:[]int{1}, IsDeleted:true, Subject:"Hello1"}
      mail2 := Mail{Id:2,Body:"Hello this is mail 2", FoldersIds:[]int{1}, IsDeleted:false, Subject:"Hello2"}
  
      session.DB("Outlook").C("Mails").Upsert(bson.M{"id": 1}, mail1)
      session.DB("Outlook").C("Mails").Upsert(bson.M{"id": 2}, mail2)
  
      var mails []Mail
  
      session.DB("Outlook").C("Mails").Find(bson.M{"IsDeleted": bson.M{"$ne": true}}).Select(bson.M{"Id": 1}).All(&amp;mails)
  
      fmt.Println(len(mails)) // Why is this 2 and not 1?????
  }
  </code></pre>