-
Back with another question. I know it's possible to query relations. But I think I need something different. Eg.:
I would need all Products where the name of Category for example == "Clothes". Was thinking of something like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
This would be up to the server, not the Swift SDK. You would need to ask this question there to see if they allow such a query. |
Beta Was this translation helpful? Give feedback.
-
@vdkdamian check the inQuery section of ParseQueryTests.swift Basically I think what you need is to just get your Category object first and match that to the Product object
I think this code should get you what you need if I understood your original question correctly. |
Beta Was this translation helpful? Give feedback.
-
Your code will probably look something like below (the guides I posted in #32 (reply in thread) further explain why): let clothesQuery = Category.query("name" == "Clothes")
let productQuery = Product.query(matchesKeyInQuery(key: “category”,
queryKey: “name”,
query: clothesQuery))
do {
let results = try await productQuery.find() // You should only use findAll when necessary is this isn’t an optimal query, you should only request what you need from the server
print(results)
} catch {
// Handle error
} Note that if you don’t find something in the Playgrounds, it’s recommended to look through SnapCat, ParseCareKit and testcases as those are intended to demonstrate how to use the SDK. |
Beta Was this translation helpful? Give feedback.
-
Okay, so I was trying a lot of things and kept failing to get it working. What do you think if we change this function
to this function:
To me it seems like most people would need the basic use and set the queryKey to "objectId". But let me know what you think! |
Beta Was this translation helpful? Give feedback.
Your code will probably look something like below (the guides I posted in #32 (reply in thread) further explain why):
Note that if you don’t find something in the Playgrounds, it’s recom…