Reputation: 1542
I have _User
, company
andjob
class.Company class has one column type Relation
pointing _User
class and Job class has one column type Relation
pointing company
class.
Now I want my users to create job where parse cloud code will find the user's company based on his user object req.user
for example,
company CP
belongs to user U
. when U
will hit the job create endpoint with his session token, a new document in the job table will be added with company CP
. Here's what i've tried but it returns all the company list
let query = new Parse.Query('company');
user.get('vz5tF2g4Pi')
.then(u => {
//query.
return query.find('users', u)
})
.then(rs => console.log('.... ', rs))
.catch(err => console.log('err ', err))
Upvotes: 0
Views: 402
Reputation: 1769
You don't actually need to fetch the user first and got the API wrong
const user = new Parse.User();
user.id = 'vz5tF2g4Pi'
var query = new Parse.Query('company');
query.equalTo('users', user);
query.find().then(rs => console.log('.... ', rs))
.catch(err => console.log('err ', err))
And you should be good
Upvotes: 1