laravel-mongodb
laravel-mongodb copied to clipboard
Cast MongoCursor result to Collection of Model
Hi, I want to know if there is a way to cast a Mongo Cursor instance from a raw query in to a Collection of Model.
DB::collection('test')->raw()->aggregate( [ ['$match' => ["status" => 'published' ]] ] );

I saw the method toArray(); that cast Mongo Cursor instance into an array
DB::collection('test')->raw()->aggregate( [ ['$match' => ["status" => 'published' ]] ] )->toArray();

So now I need to cast each BSONDocument to a Model.
I want know if there is an efficiente way to do so. I think this is exactly what the package does under the hood
Thanks
I think that PR can will resolve this issue