by colinmcd · 4y ago · 0 comments
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 :)
with tag_names := {"angular", "nestjs", "cypress", "nx"},
select BlogPost {
title,
tag_names := .tags.name,
match_count := count((select .tags filter .name in tag_names))
}
filter .match_count > 0
order by .match_count desc;SQL definitely must be replaced, but the silly pseudo English syntax is one of the things we want to get rid of, not retain.
Found this: https://github.com/edgedb/edgedb-rust