-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
support filtering by (non-)existing relationships #551
Comments
an I agree, |
I would say that filtering by parent and by children are different tasks. Also, 'isEmpty' and 'hasAny' sound more natural for a collection. |
I consider them to be analogous: one is filtering by the (non-)existence of a to-one relationship and the other is doing the same for to-many relationships. Why do you think that there would inherently be less popular usecases for filtering by to-many relationships? |
From the JADNC point of view the cases are kind of similar. But field types are different: a single object and a collection of objects. Filtering by the parent is very popular: get the list of subfolders, get posts made by the user, get settings for the project, etc. Filtering by children is rarer. It may be useful in some data processing or report building tools to find, let's say, jobs that have no applicants, or empty workspaces. It's hard to imagine something like this in a simple web/mobile application (a typical consumer of JSON API). Data processing tools, due to performance reasons, use direct storage access. |
@unicrus i can have multiple children, only one child, and multiple parents, and only one parent. It is very similar. It is just not in your use case. What you consider a parent is just a relationship. If we are to support your use case we are first going to consider a more generic approach so it can be applied to more usescases, therefore helping more people. I like to filter by children, maybe I want to find all leaves in a graph? This would require me filtering on all items that don't have children. |
Description
In #548 support for filtering by (non)-null to one relationships was added:
/children?filter[parent.id]=isnull
. As discussed in that issue, ideally we would like to allow to filter without having to reference the primary key.To that end, we want to support filtering by (non)-existing relationships by using something like this:
/children?filter[parent]=isnull
for to one relationships/parents?filter[children]=isnull
for to many relationshipsNote that when dealing with to many relationships,
isnull
might not be the most intuitive choice from a semantic point of view, because in C#/EF a to-many relationship is aIEnumerable
which can be empty but is usually never null. For the latter we could therefore consider to introduce eg.isempty
orisset
, and for consistency we could use the same in the case of to one.The text was updated successfully, but these errors were encountered: