Reputation: 394
this is the structure of my Database with the classes:
User -> objectId (String) username (String)
Friends -> objectId (String) toUser (Pointer <_User> ) fromUser (Pointer <_User> )
My goal is to retrieve the users with the usernames, which matches the columns toUser and fromUser with a specific Id. The Pointer of toUser and fromUser variable is the objectId of the table "User"
How my query should be?
I tried this one but it doesn`t work
Parse.Cloud.define('FriendsQuery', function(req,res) {
const friends = new Parse.Query("Friends");
friends.equalTo("toUser","fEjQgAPvDO");
const userQuery = new Parse.Query("User");
userQuery.matchesQuery('friend', friends);
userQuery.find().then((results) => {
res.success(results);
})
.catch(() => {
response.error("user lookup failed");
});
});
I have included only the toUser column in this query
Any idea?
Thank You
Upvotes: 0
Views: 855
Reputation: 980
The third line should look like this
friends.equalTo("toUser", { "__type": "Pointer", "className": "_User", "objectId": "fEjQgAPvDO" })
Upvotes: 0
Reputation: 63
The third line in your code should look like this
friends.equalTo("toUser",{__type:"Pointer", className:"User", objectId:"fEjQgAPvDO"});
Upvotes: 0