0

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))

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.