Filtering products by custom model field via swell-js #9
Answered
by
logeshswell
logeshswell
asked this question in
Help
-
How to implement a usecase to fetch a list of food dishes available in a particular restaurant, where there can be 'm' restaurants each having 'n' food dishes? |
Beta Was this translation helpful? Give feedback.
Answered by
logeshswell
Nov 28, 2022
Replies: 2 comments 1 reply
-
import swell from 'swell-js'
swell.init('store_id', 'public_key')
queryParams = {
restaurant_id: 'dominos_id_value',
expand: 'restaurant'
}
products = await swell.products.list(queryParams) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
logeshswell
-
Can I use slug value ("dominos") instead of auto-generated id for querying products?Yes, you can handle it in 2 ways.
Please follow the below instructions for the recommended approach:
{
"secondary_field": "slug"
}
Now, you can use the slug value instead of auto-generated id to query the products of your choice: queryParams = {
restaurant_id: 'dominos', // slug value
expand: 'restaurant'
}
products = await swell.products.list(queryParams) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slug
("dominos") andname
("Domino's Pizza") along with auto-generated fieldsid
,date_created
anddate_updated
.content
namespace.restaurant_id
) that is mapped to the restaurant model.restaurant_id
refers to the restaurant to which the food dish belongs.