I have a list of file groups with tags. Assume th...
# prisma-whats-new
l
I have a list of file groups with tags. Assume that this is my data (only one file group): https://cl.ly/1u3h1k0o3j0y I want to return that same data by selecting the tag enums "ImageHero" and "ImageVehicle", however the following query returns empty. Any ideas on my error? https://cl.ly/453H1g0C3F1w
j
And if you change the
AND
by a
OR
?
l
Then all file groups with ImageHero or ImageVehicle come back. In other words, file groups without
ImageHero
will return
j
And if you add the last tag
ImageScale
, you got it?
l
The last tag isn't relevant to the query. I need
Copy code
SELECT * from fileGroups
JOIN tags_fileGroups as jointable
   ON fileGroups.ID = jointable.fileGroupId
JOIN tags
   ON tags.id = jointable.tagsId
WHERE tags = 'ImageHero' and tags = 'ImageVehicle'
j
hum... the query seems good
l
That's what I'm saying 🀣😒
j
^^
and what about make directly a array of the enum instead a array of the type β€œtag”?
is it work is you just add one tag?
l
yes...
AND: [{ tag: ImageHero }]
returns all Image Hero tagged file groups
I have a feeling I'm misusing
AND
somehow
j
maybe, without the playground i can test some queries
but @nilan may have the solution?
n
tags = 'ImageHero' and tags = 'ImageVehicle'
this is never true.
I don't understand your requirement. A string can only be one value at a time.
oh
l
Maybe I'm SQL rusty. I want to return nodes where both tags are present
n
maybe this is what you want
Copy code
where: { AND: [{tags_some: {tag: "a" }}, {tags_some: {tag: "b" }}] }
will select file groups that have at least one related tag
a
, and at least one related tag
b
l
Nilan wins!
😎 2
πŸ‘ 1
n
your original query said "all file groups that have at least one related tag, and that tag is
a
and `b`" which is always false
l
Interesting. I'm going to need to process that one in my head. Thanks for the explanation!
πŸ‘ 1