I am working with node.js
I am trying to filter the collections I have to exclude the collection 'outlets' and retrieve all other collections, but I can't seem to figure out the syntax. I've tried:
db.listCollections({filter: 'outlets'}).toArray((err, docs)
Any suggestions?
Your filter is mis-constructed. Instead of saying 'filter', you have to specify the field to filter by name in a filter document, like this for example:
db.listCollections({name: 'outlets'});
That will include only the outlets collection, however. To exclude the outlets collection, you need to use the $ne operator
db.listCollections({name: {$ne: 'outlets'}});
See the guidance in the docs on the listCollections command for more details.
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