4

I am currently working on one application which is using parse API in php. The scenario is I am having 3 tables named User, Kids and JournalEntry. User has many Kids and Kids has many Journal Entry. So its like Kids table has User Pointer and JounralEntry also has 2 pointers named KidsID and UserID. When I try to get the data from the JournalEntry table, it is taking too much time because of the 2 queries which I fire. First query for fetching the data from the kids table and second one is for the JournalEntry table on the basis of first query's objectid.

Is there any way in Parse API that we can directly fire one query like following:

SELECT * FROM JounralEntry
WHERE Kids.objectId = JounralEntry.kidsID AND User.objectId = JounralEntry.UserID ?

1 Answer 1

1

You can use Relational Queries to achieve that

curl -X GET \
  -H "X-Parse-Application-Id: " \
  -H "X-Parse-REST-API-Key: " \
  -G \
  --data-urlencode 'where={"KidsId":{"$inQuery":{"where":{REPLACE_WITH_YOUR_QUERY_HERE},"className":"Kids"}}}' \
  https://api.parse.com/1/classes/JounralEntry

Please correct any wrong field in the query.

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

2 Comments

Hi kodingralph, I appreciate your answer but my problem is I have to find related kidsID from the user's table and then on the basis of that result i can fire query on the journalEntry table to match the first queries result with jounralEnrty's kidsID.
You can still use Relational Queries. What you need to use is $inQuery parameter. Check my edited answer for example or in the docs I posted. If you still had issues, adjust your question with a more detailed use case.

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.