MongoDB Exception: unknown operator $oid

I’m using yii2 mongodb and only when ‘enableAutoLogin’ is set to true in backend/config/main.php


'user' => [

            'identityClass' => 'common\models\User',

            'enableAutoLogin' => true,

            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],

        ],

i see this error from debug mode:


MongoDB Exception – yii\mongodb\Exception

unknown operator: $oid

Caused by: MongoDB\Driver\Exception\ConnectionException

What’s the problem?

Thanks in advance!

Typecast on


getId()

of User model. like


/**

 * @inheritdoc

 */

public function getId()

{

    return (string) $this->getPrimaryKey();

}

source