How to get indices using Jenssegers Mongodb

  indexing, laravel, mongodb, php

I’m needing to get the indexes of a collection in mongodb using laravel, I know that in mongo compass you can use the $ indexStats which returns the indexes, try to replicate the same as follows

DB::connection('mongodb')->collection("audience")->timeout(-1)->raw(function($collection){
    return $collection->aggregate([
        [
           '$indexStats' => new stdClass()
        ]
    ], ["allowDiskUse" => true]);
});

But with a dd () check the result and it was the following

MongoDBDriverCursor {#2009}

The truth is that I would not know what that is, if someone knows what I am doing wrong or how to obtain the indexes it would help me a lot

Thank you very much for your time

Source: Laravel

Leave a Reply