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

New feature: findLast(int), findFirst(int), findRandom(int) #1050

Open
crysan opened this issue Apr 20, 2015 · 9 comments · May be fixed by #6778
Open

New feature: findLast(int), findFirst(int), findRandom(int) #1050

crysan opened this issue Apr 20, 2015 · 9 comments · May be fixed by #6778

Comments

@crysan
Copy link

crysan commented Apr 20, 2015

Hi!
Now we have.findAll () and.findFirst ().

And you can add?:
.findLast(10) - hoose the last 10 items
.findFirst(14) - choose the first 14 elements
.findRandom(42) - choose 42 random element

@cmelchior
Copy link
Contributor

I could see use cases for both findLast(int) and findFirst(int), but to be honest I am not sure that adding findRandom(int) has enough use cases to warrant bloating the number of API methods.

Also the use cases for these methods might be covered by adding LIMIT #544, but it is worth a discussion.

@crysan
Copy link
Author

crysan commented Apr 21, 2015

LIMIT по сути тоже самое. Но зачем добавлять новый метод, когда можно модернизировать существующий?
findRandom в основном нужна при разработке приложения. Есть 10000 записей и при проектировании приложения (или даже самой)

@crysan
Copy link
Author

crysan commented Apr 21, 2015

Sorry.

LIMIT essentially the same. But why add a new method, when it is possible to upgrade the existing one?

findRandom mostly needed when developing an application. There are 10,000 entries, and the design of the application ( or even most of the base ), it is desirable to display a new kind of data.

@cmelchior cmelchior changed the title New function idea New feature: findLast(int), findFirst(int), findRandom(int) Apr 21, 2015
@crysan
Copy link
Author

crysan commented Jun 10, 2015

There are changes?

@cirosomma
Copy link

Hi Crysan,
I've just joined on realm. I'm studying it and when I'll be able, I'll build it.

@crysan
Copy link
Author

crysan commented Jun 15, 2015

Thank you! I am waiting for the result.

@yolapop
Copy link

yolapop commented Jul 15, 2015

I think it would be useful to have findRandom. For example, I need to display item recommendations but I don't have the recommendation data yet, so it'd be nice to just show 5 random items at first.

@yograterol
Copy link

findRandom +1

@emanuelez
Copy link
Contributor

Be aware that RealmResult is lazy and does not copy data to memory at any point.
That means that the proposed methods are very easily replaced with RealmResult.get() with no additional memory or performance cost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants