I have Posts
data table, which get assigned with an automatic ownerId
based on the logged in user that posted them (Those without an ownerId are considered anonymous).
I would like retrieve the Posts with their User data (name, email) but it seems the relationship is not reflected in both the javascript SDK:
const PostsStore = Backendless.Persistence.of(Post);
var query = new Backendless.DataQuery();
query.options = {relations:["ownerId"]};
export function getPosts(){
return PostsStore.find(query);
}
Also using the REST api does not yield the desired results:
https://api.backendless.com/v1/data/Post?loadRelations=ownerId
or
https://api.backendless.com/v1/data/Post/DE14D6F4-00B5-D47C-FFC5-57B078847300?loadRelations=ownerId
It seems whatever I do, I can’t get the User data…
Just getting something like this ( I will remove authorEmail once I have the relationship working):
{
"image": "https://api.backendless.com/20B6BCEC-3854-082A-FFEB-62B6E777F500/v1/files/*********/******.jpg",
"authorEmail": "***************",
"created": 1465818079000,
"___class": "Post",
"title": "gim",
"ownerId": "C35E75A4-1BCB-15B8-FFDB-9C290C16D700",
"updated": null,
"objectId": "DE14D6F4-00B5-D47C-FFC5-57B078847300",
"__meta": "{\"relationRemovalIds\":{},\"selectedProperties\":[\"image\",\"authorEmail\",\"created\",\"___class\",\"title\",\"ownerId\",\"updated\",\"objectId\"],\"relatedObjects\":{}}"
},
Any suggestions? Thanks!