Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any plans for querying exact amount of objects ? #3649

Closed
XDXO opened this issue Oct 18, 2016 · 3 comments
Closed

Is there any plans for querying exact amount of objects ? #3649

XDXO opened this issue Oct 18, 2016 · 3 comments

Comments

@XDXO
Copy link

XDXO commented Oct 18, 2016

Goal

As far as I know, Realm lacks of an option for limit / paging.
Most ORMs as well as various databases support the option.
This feature will be needed in case that I want to get only 5 newest feeds.
realm.between(String fieldName, ..., ... ) does not guarantee querying exact amount of objects.
Although Realm uses lazy loading, I think this feature enhances readability and productivity for programming.

Expected Results

> // TODO : Get only 10 event objects.
> Realm realm = Realm.getDefaultInstance();
> List<Event> query = realm.where(Event.class).greaterThan(Event.FIELD_CREATED_AT, oldest).limit(10);
@Zhuinden
Copy link
Contributor

Duplicate of #544

@XDXO XDXO changed the title Is there any plans for querying exact amount of objects ? Is there any plans for querying exact amount of objects ? T:Feature Oct 18, 2016
@XDXO XDXO changed the title Is there any plans for querying exact amount of objects ? T:Feature Is there any plans for querying exact amount of objects ? Oct 18, 2016
@cmelchior
Copy link
Contributor

Hi @XDXO
This is already being tracked here #544. Note that since Realm lazy load all data you don't have the same memory concerns as seen in normal ORM's.

I'll close this as an duplicate and let discussion continue in #544

@Zhuinden
Copy link
Contributor

Zhuinden commented Oct 18, 2016

Really though, this is easily solved by returning a maximum of Math.min(5, results.size()) in your RecyclerView's Adapter in getItemCount()

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants