MongoDB Delete documents that don't have given field
<p>Hello I have a beginner question I suppose... 
I've had a look around but could not find the answer</p>

<p>I have the following collection of <code>users</code> that I'd like to clean before I redefine my user model - how can I remove all documents that don't have the field firstname, or lastname in the following collection ?</p>

<pre><code>{ "_id" : ObjectId("57615777a629d16a4c604cce"), "firstName" : "Hector", "lastName" : "yoyo", "email" : "mail@test.tld", "createDate" : ISODate("2016-06-15T13:26:15.900Z") }
{ "_id" : ObjectId("57615849a629d16a4c604ccf"), "firstName" : "Arnaud", "lastName" : "yaya", "email" : "mail@dsdsasadsadsad.tld", "createDate" : ISODate("2016-06-15T13:29:45.517Z") }
{ "_id" : ObjectId("57615c33a629d16a4c604cd0"), "createDate" : ISODate("2016-06-15T13:46:27.224Z") }
{ "_id" : ObjectId("57615ff943d8b1a74c4d4216"), "createDate" : ISODate("2016-06-15T14:02:33.352Z") }
</code></pre>

<p>I know I can remove these one by one but I imagine there's a better solution :)</p>

<pre><code>db.users.remove( { "_id" : ObjectId("57615ff943d8b1a74c4d4216") } );
</code></pre>

<p>Thanks </p>