Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cast MongoCursor result to Collection of Model #2196

Open
Labels
@Giacomo92

Description

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' ]] ] );

Schermata 2021年02月06日 alle 10 27 40

I saw the method toArray(); that cast Mongo Cursor instance into an array

DB::collection('test')->raw()->aggregate( [ ['$match' => ["status" => 'published' ]] ] )->toArray();

Schermata 2021年02月06日 alle 10 31 08

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /