How do I remove all documents in a collection where a field's value isn't null? Basically the MySql query version would be like this:
// MySql query
DELETE FROM companies WHERE createdBy != NULL
// What I tried but did not work.
$this->mongo->companies->remove(array('createdBy' => true));
I don't even know if it is possible, if anyone could help me with this I would appreciate it ;)
Thanks :)
You can do it easy via not equal operator:
db.companies.find( { createdBy : { $ne : null } } );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With