Ionic+ Parse.com - nested queries how to?


#1

Hello All,

I am using Parse.com as a backend for my app.

I have 2 classes Post and Comment. Comments contain a parent pointer to Post class.

What is the best way to build a query that fetches both Post’s and associated Comments in one call?

Thanks
Skota


#2

Donno how it’s done via Parse but you can respond with nested JSON. That also depends on how you structured the post-comment association (but that’s backend).

On the front-end, just use $http.get (https://docs.angularjs.org/api/ng/service/$http)


#3

Yeah if parse.com provides such a url-scheme.
If not you have to send multiple request via $http.

I think parse uses mongodb or another documentbased databasesystem?

Then you could build your post schema with their comments.
your Post “class” gets another key “comments” it is an array of objects -> with the keys of your comment “class”.


#4

you do it with Parse Cloud Code - make the query (joining the classes) in the cloud code then use either the REST api or JS sdk to call the cloud code function and it will return your dataset


#5

you should restructure your data model and let parse handle the relationships for you

https://parse.com/questions/how-to-retrieve-parent-objects-with-their-children-in-one-call-javascript-api