I have the following parse query:
loadAllFriends(params: any = {}): Promise<User[]> {
const page = params.page || 0;
const limit = params.limit || 20;
const query = new Parse.Query(User);
const user = Parse.User.current();
const relation = user.relation('likes');
query.equalTo('likes', user);
query.descending('updatedAt');
query.skip(page * limit);
query.limit(limit);
return query.find();
}
...and i load the data in page.ts like:
const users = await this.userService.loadAllFriends(this.params);
console.log(users);
for (let user of users) {
this.users.push(user);
}
... So this code it queries const user = Parse.User.current(); in likes relation column, checks if user is there and returns the results.
I need exact the opposite, with the anterior query i get the friends, but i need to get the followers. The followers are stored in user -> likes relation column:
How can i query user like:
const user = Parse.User.current();
query.equalTo('objectId', user.id);
... and here get the likes relation data from this user?
I don't think that you can do what you're trying to with a relation. I think that you'll need to model these relationships with a table:
{ fromUser, toUser, status }