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

Should All function be able to take queries? #29

Open
RobStallion opened this issue Jan 3, 2019 · 2 comments
Open

Should All function be able to take queries? #29

RobStallion opened this issue Jan 3, 2019 · 2 comments
Assignees
Labels
discuss enhancement New feature or request question Further information is requested technical

Comments

@RobStallion
Copy link
Member

Should we be able to pass a query to the all function?

Currently all gets all the the distinct :entry_ids from the database, orders the results and removes any values where deleted is true.

This works well but does not allow us to do any further database queries.

For example, if you wanted to retrieve a list of all users from a user table who were under 50. With Ecto.Repo you would be able to pass in a query that looks something like...

query = from(u in user, where: u.age < 50)
Repo.all(query)

The database does all the logic and returns only the data you need.

With the current all in alog we would need to retrieve all users and then filter them ourselves in app.

@Danwhy @nelsonic any thoughts/suggestions on how we can extent the all function to all users to pass in any query but still keep/use the current query?

@RobStallion RobStallion added question Further information is requested enhancement New feature or request discuss technical labels Jan 3, 2019
@Danwhy
Copy link
Member

Danwhy commented Jan 3, 2019

My first thoughts are that we can either use another subquery when a query is given as a parameter, or we reduce the queries into a single one, similar to what we're doing with the get_by function.

We'd have to try them out to see if either of them actually work/which is better though

@nelsonic
Copy link
Member

nelsonic commented Jan 4, 2019

@RobStallion great question and thank you for capturing it in this issue! 👍
We should attempt to make our all/1 function as similar to Ecto's Repo.all/1 as possible
to minimise the friction to adoption or "cognitive load" people have when learning how to query an append-only log.

As @Danwhy says, we should try this out and see how simple we can make it.
Ideally all queries in alog should be Ecto Queryables so that they can be chained.

@nelsonic nelsonic removed their assignment Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss enhancement New feature or request question Further information is requested technical
Projects
None yet
Development

No branches or pull requests

3 participants