We have a large number of users, we would like to filter only the users that have 3 or more posts with type blog
Add an extension to the existing PostFilter to take into account how many items of the relation there are and use an intFilter to match certain requirements
The the none and every field might be overkill for this, since the count of the amount of items that not match a requirement does not make a lot of sense but probably someone will find a use for it :-)
export declare type CountPostFilter= {
count: IntFilter,
where?: PostFilter,
};
export declare type PostFilter = {
every?: PostWhereInput | null;
some?: PostWhereInput | null;
none?: PostWhereInput | null;
}
All users with more than 10 posts
users(where: {
posts: {
count: { gt: 10 },
},
}):
All users with more than or equal 4 posts with type 'blog'
users(where: {
posts: {
count: { gte: 4 },
where: { some: { type: {equals: "blog"} },
},
}):
All users with only posts with type 'blog' and at least 5 posts
users(where: {
posts: {
count: { gte: 5 },
where: { every: { type: {equals: "blog"} },
},
}):
All users that have no posts with type 'blog' but have 10 posts with another type
users(where: {
posts: {
count: { gte: 10 },
where: { none : { type: {equals: "blog"} },
},
}):
This will be solved by #1 馃檪
Any ETA on implementation of #1 ? Seems in design right now, but I don't know how long it takes from design to implementation to beta to release :-)
@maartenraes We're actually implementing this one right now! Unfortunately, I can't give an ETA since there's still some unknowns to work through, but group by support is one of our top priorities.
Most helpful comment
@maartenraes We're actually implementing this one right now! Unfortunately, I can't give an ETA since there's still some unknowns to work through, but group by support is one of our top priorities.