Yii2 MongoDB: check if collection exists?

How do you check if a collection exists with Yii2 MongoDB?

With the original PHP driver you can check the output of MongoDB::getCollectionNames and then check if the collection is there. Couldn’t find a way to do that with Yii2 MongoDB layer.

I begin to question do I need to use Yii’s layer for Mongo at all, what are the benefits of using it?

Figured out how to do that

In Yii’s Database class you have a public var $mongoDb which is the PHP MongoDb Database object.

So you can query it like this: