Hello,
I have a one-to-many relationship between two tables, Person and Note, in which one person owns many notes.
I am running a search query on notes, and would like to load properties from the parent object Person during the query. Choosing which properties to load would be optimal, but if that’s not possible, loading the entire object will do and I’ll just parse when I need out of that object.
Is there a way to condense this into one query through the JS SDK, or do I need to split it into two queries?
Previous discussions in this arena:
http://support.backendless.com/t/inverse-of-a-relationship
http://support.backendless.com/t/how-to-get-parent-table-details-from-child-table
https://backendless.com/feature-28-loading-related-data-objects-the-semi-lazy-approach/
https://backendless.com/feature-59-recursive-object-references-in-persistence-objects/
These seem to describe either 1) forward relational querying (getting children loaded when querying parents) or 2) loading the reverse in two steps.
One thing I noticed: my JS model that I downloaded from the server didn’t define a reverse relational property on the Note type. I have tried to manually define this property, but a query against it fails (see below)
[model]
/**
@name Note#person
@type Person
*/
this.person = undefined;
[query]
noteQuery.options = { relations: [ 'person' ] };
{ code: 1023,
message: 'Unable to retrieve data. Query contains invalid object related properties.' }