tduccuong
Hi all,
I am new to Elixir and are using this lib GitHub - elixir-mongo/mongodb: MongoDB driver for Elixir · GitHub to work with MongoDB. The doc says it has “Streaming cursor” feature, but the source code implements only Enumerable protocol for the cursor returned by the Mongo.find function.
There is no doc about a cursor API, or do I miss something?
Thanks a lot!
Trending in Announcing
Hey everyone!
Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application.
This library uses Erlang esaml to provide
plug enabl...
New
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries.
offset-based pagination with...
New
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi all!
I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas.
You...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
This showed up on my feed.. anyone heard of it? Just hype?
Ox Alpha is a reasoning model designed for coding, sustained ag...
New
It’s not that it’s vocabulary is too advanced. It’s something worse.
I get lost trying to follow even a paragraph written by Claude. It’...
New
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
Introductory paragraph
I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Ankhers
What is it you are trying to accomplish?
tduccuong
Thanks a lot for answering!
So, I want pagination in my app. In my website landing page, i would show first 10 items of a search query, then provide buttons to view next / previous 10 items…
I did not find an API that allows me to do that in the driver? E.g., something like:
Mongo.find_next(.., cursor, ...)Or if there is, could u pls show me?
Ankhers
Since this is for a website, you would not have access to the same cursor between requests. For something like this, you would structure your query like
Then you are free to render the results as you see fit.
tduccuong
Thanks a lot, I will try this and give feedback…
tduccuong
confirmed that it works! thanks a lot!
Ankhers
Glad I could help!
tduccuong
When use this method with
sort: %{<field>: <order>}option, it seems the sorting is not done in the entire result space but only on the returned batch, unless I setpage = 0andlimit = <number of all items in DB>E.g., say I have 10 items in DB labeled 1 → 10. Say an unsorted query, with
limit = 10, returnsNow if I set
limit = 5, and sort increasing order, then withpage = 0, 1, the two returned batches are:and
What I want are:
and
Could u pls show me the way to achieve that, if there is?
Thanks a lot!
Ankhers
I am not seeing the same behaviour.
Would you be able to show something similar to what I just did there? If you can, I may be able to help figure out what is going wrong.
tduccuong
hmm I noticed that, for every returned batch, if I do
Enum.reversethe list, then the order is correct as I wanted.Sorry I don’t have an example right now and cannot share data, but here is two snippets with the later does what I want:
and
The
DbSrvmodule is just a convenient wrapper aroundMongomodule of yours.tduccuong
My bad, I did an
Enum.reducein theDbSrvmodule! Sorry for ur time! Everything is fine now.Thanks a lot!