PepeNietnagel
PepeNietnagel

Reputation: 239

Set option bypassDocumentValidation for Laravel MongoDB (jenssegers/mongodb)

I try to update my Eloquent model while bypassing the validation (because some items break their schema).

As I understand the mongodb package, it should be possible to pass an option ['bypassDocumentValidation' => true]

I tried to set this option both in the DB config

            'driver'   => 'mongodb',
             ...
            'username' => env('MONGO_DB_USERNAME'),
            'password' => env('MONGO_DB_PASSWORD'),
            'options'  => ['bypassDocumentValidation' => true]
        ],

as well as using the update

Brand::find($brand->_id)->update([$data, ['bypassDocumentValidation' => true]);
or 
$brand->save(['bypassDocumentValidation' => true]);

Every time, I still get the validation error ("Document failed validation").

How can I pass the option to MongoDB?

Upvotes: 0

Views: 110

Answers (0)

Related Questions