I am trying to get from a User’s perspective, all the services he has assigned to them. Since I cannot query from child to parent, I am going from the highest point and filtering down. This is just filler code for now with actual user variables coming later.
When searching by user’s name, i am receiving the entire service results where the serviceProvider has the name i want, but I can also see the other services (1:N) that do not belong to that user. How do I not get those extra results?
Can you explain more on this? I’ve seen on other support tickets it was said that it was not possible. If i have the service details, how do I work up to the House table that it belongs to?
For the fix, I tried that in the beginning and had this same issue. I thought using the ‘having’ clause would fix it since Houses → Openings and Openings → Services are 1:N. Here is what I am receiving.
For the fix, I tried that in the beginning and had this same issue. I thought using the ‘having’ clause would fix it since Houses → Openings and Openings → Services are 1:N. Here is what I am receiving.
The reason is you looking for Houses that fit your requirements - and it’s correct, you get one that has service with provider Hart, but you load ALL related service objects for that House.
If you want to get only one needed service you could:
Manually filter current response.
Make a request in the service table - not Houses.
Can you explain more about this?
Here you could find some information about it.
Also, I could offer you a request to the service table with next whereClause
Opening[services].Houses[openings].status != 'Closed' AND serviceProvider.name = 'Hart'
Regarding child-to-parent navigation. Suppose you have a specific service object. Here’s a query to get all the houses that indirectly reference the service:
openings.services.objectId = 'objectId of the service object goes here'
For the issue with the wrong serviceProvider getting pulled in, please let me know your application ID and I will give it a try.
I was trying to work on a filter for it, but being that the filter item is so deep and I still need all parent data, it’s beginning to confuse me. Thank you Mark for looking at this for me.
The query with a condition to get Houses with the service provider having a specific last name gets you the houses that indeed have that related service provider. However, when you request relations, the service will return all related objects (not the ones constrained by the where clause). The reason is by design the where clause applies only to the primary table (Houses in this case).
A solution may be a two-step approach to get services:
Get Houses objects without relations.
Iterate over Houses and get related services with the following query:
Opening[services].Houses[openings].objectId = 'objectId-of-the-current-Houses-object' and serviceProvider.lastName = 'Hart'