title: Mongo projection to set value based on if a key exists or not
body: <p>I have a mongo document that looks something like:</p>
  
  <pre><code>{
    bookings: [
      {complete: true, name: "John", checklist: {a: 1, b: 2}},
      {complete: false, name: "Kate"},
      {complete: true, name: "Mary", checklist: {a: 1, b: 2}}
    ]
  }
  </code></pre>
  
  <p>I have a aggregation with a projection that looks like:</p>
  
  <pre><code>{
    $project: {
      'bookings.complete': 1,
      'bookings.name': 1
    }
  }
  </code></pre>
  
  <p>Which returns the array of bookings, with only the complete and name keys. </p>
  
  <p>I now want to add a key called <code>hasChecklist</code> that is <code>true</code> if the checklist exists, and <code>false</code> otherwise.</p>
  
  <p>But I'm stuck because this projection will always return <code>true</code> for some reason :( </p>
  
  <pre><code>{
    $project: {
      'bookings.complete': 1,
      'bookings.name': 1
      'bookings.hasChecklist': { $ne: ['$bookings.checklist', null] }
    }
  }
  </code></pre>
  
  <p>Basically I get </p>
  
  <pre><code>{
    bookings: [
      {complete: true, name: "John", hasChecklist: true},
      {complete: false, name: "Kate", hasChecklist: true},
      {complete: true, name: "Mary", hasChecklist: true}
    ]
  }
  </code></pre>
  
  <p>When I want</p>
  
  <pre><code>{
    bookings: [
      {complete: true, name: "John", hasChecklist: true},
      {complete: false, name: "Kate", hasChecklist: false},
      {complete: true, name: "Mary", hasChecklist: true}
    ]
  }
  </code></pre>
  
  <p>Anyone know what the correct expression in the projection should be?</p>