Search code examples
parse-platform

Why do I sometimes get embedded attributes and sometime not?


I'm using parse-platform with React-Redux and thunk.

If I make a query for objects which have pointers as attributes, sometimes I get the embedded attributes of the pointer and sometime I don't, is this normal behaviour? It means having to make lots more queries for the pointer attributes as you can't be confident they will be in the original results.


Solution

  • As you state correctly sometimes Parse fetches the pointers of an object and sometimes it doesn't.

    In order to ensure that the query will bring the pointers of the object alongside all its attributes its a good idea to use the include method as query.include('pointerAttribute').

    In order to ensure that only some attributes will be fetched and the rest won't, then it is a good idea to use the select method query.select('attribute1toselect', 'attribute2toselect').

    Using select is much better if not going to use all the attributes as the payload's weight in the response will decrease and the frontend will have to deal with less data.