How to Filter Query Results by a Property that is a Reference
3 replies
Last updated: Sep 7, 2020
P
Hi, I was wondering how I could filter query results by a property that is a reference? i.e. i have X amount of “downloads” and want to filter them by a given “tag”. “tags” is an array of references.
Sep 7, 2020, 7:56 AM
P
This could be it:
*[_type=="tag" && title == $tag]{
title,
"downloads": *[_type=='download' && references(^._id)] {
title
}
}
Sep 7, 2020, 8:17 AM
H
If you have a document called, for example:
toFilter
that references a set of
tags
that you want to filter by, you could do the following: