laravel-mongodb
laravel-mongodb copied to clipboard
how to update only one record ?
I have used both of those:
Product::limit(1)->update(['xxx' => 'yyy']);
and
Product::update(['xxx' => 'yyy'], ['multi' => 0, 'multiple' => 0]);
and none of them worked
Good morning sir
Hi @samerzaki you only want to update one record, no matter which is in the DB?
if this is the case this should help you:
$Product = Product::take(1)->skip(rand(0,$noOfProduct-1))->first();
$Product->xxx = "yyy";
$Product->save()