Can I get the result of mongodb_driver "command" function as stream?

Hi !,

I want to access the result fo “command” function of mongo_driver (https://hexdocs.pm/mongodb_driver/Mongo.html#command/3) as stream.

Other functions like “find” return the stream (cursor), but the “command” function returns only parts of the result.

When I call ,
Mongo.command(conn, [find: "My_Collection" , filter: %{}])

it returns

  {:ok,
     %{
           "cursor" => %{
              "firstBatch" => [
                            %{  DOC }, 
                            %{  DOC }, 
                             ....
                           ]

only some parts of the DOCs is in the “firstBatch” list.

Can I get the result of “command” function as stream ? ( I want to get the whole result DOCs.)

Or , how can I get the whole result of the “command” function call ?

Thanks,

I am no expert on MongoDB nor the mongodb_driver library but from a quick glance it seems that if you instead use the slightly higher-level functionMongo.find you get back a so-called cursor which is how (in MongoDB but also many other databases) you’re able to lazily iterate through a larger collection of documents.

It seems that this cursor result is a (lazy) iterator that supports using Elixir’s built-in Stream and Enum functions with it.