How do I get posts that have a certain category set to it? #913
Answered
by
jmikrut
ahmetskilinc
asked this question in
Q&A
-
Currently I'm using QueryString like so: const stringifiedQuery = qs.stringify(
{
where: {
category: {
name: {
equals: req.query.name,
},
},
},
},
{ addQueryPrefix: true }
); But I am still getting back all posts instead of the ones with a certain category. Post: {
/*...*/
title,
category: Category,
/*...*/
}
Category: {
id,
name,
} How would I write my QueryString so I only get back the posts with a certain category? |
Beta Was this translation helpful? Give feedback.
Answered by
jmikrut
Aug 11, 2022
Replies: 1 comment 2 replies
-
Hey @ahmetskilinc — here's how you'd do that: const stringifiedQuery = qs.stringify(
{
where: {
'category.name': {
equals: req.query.name,
},
},
},
{ addQueryPrefix: true }
); You have to use dot notation to query on nested relationship fields, but this should be golden! |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
ahmetskilinc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @ahmetskilinc — here's how you'd do that:
You have to use dot notation to query on nested relationship fields, but this should be golden!