How to create mongodb collection on runtime while executing Yii2 code

Hi,

I need to create mongodb collection while executing code, by checking wheter the collection is exists or not.

I tried below things

Yii::$app->db->createCommand()-> createCollection(“collection_name”);

but collection not created.

Please help.

Did you read this?

1 Like