extvision

extvision

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 (Mongo — mongodb-driver v1.6.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,

First Post!

Qqwy

Qqwy

TypeCheck Core Team

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.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement