|
EdgeDB employee here. I couldn't have asked for a better question to demonstrate the power of subqueries! Here's how I'd do this in EdgeQL: with tag_names := {"angular", "nestjs", "cypress", "nx"},
select BlogPost {
title,
tag_names := .tags.name,
match_count := count((select .tags filter .name in tag_names))
}
order by .match_count desc;
Which would give you a result like this: [
{
title: 'All the frameworks!',
tag_names: ['angular', 'nestjs', 'cypress', 'nx'],
match_count: 4,
},
{
title: 'Nest + Cypress',
tag_names: ['nestjs', 'cypress'],
match_count: 2,
},
{
title: 'NX is cool',
tag_names: ['nx'],
match_count: 1,
},
];
|
So to only get blog posts with matching tags we would need to add a filter „match_count > 0“, right?
Update: I am very excited about EdgeDB :)