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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









