1

Can a Parse object be fetched with object.fetch and at the same time include its object references as in query.include?

Here is the query example:

let query = new Parse.Query("MyCollection");
query.include("MyObjectReference");
return query.find();

How to do it with a fetch command?

3 Answers 3

3

Parse JS SDK >= 2.0.2

It is possible to fetch one or multiple objects with include:


Parse JS SDK < 2.0.2

It's not possible as the docs say:

By default, when fetching an object, related Parse.Objects are not fetched. These objects’ values cannot be retrieved until they have been fetched like so:

var post = fetchedComment.get("parent");
post.fetch({
  success: function(post) {
    var title = post.get("title");
  }
});
Sign up to request clarification or add additional context in comments.

1 Comment

This is not correct. See fetchWithInclude(). parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html
1

Stumbled onto this via a google search and wanted to correct the record. The accepted answer to this is not correct.

You very much CAN do what the OP is asking by using fetchWithInclude([key1,key2.subkey,key2.subkey2,etc]);

See: https://parseplatform.org/Parse-SDK-JS/api/master/Parse.Object.html

1 Comment

The OP is me and the accepted answer I gave myself was correct until August 2018. I updated my answer, thanks for pointing this out.
0

A fetch command in Parse is essentially a find with only a "where equal to" on a single object id. So you can simply make a query for a single object id and Parse will handle it like a fetch, e.g. you can restrict a table to only allow fetch and this single object id query will still pass. I haven't read into the code, but I believe that a fetch is essentially a single object id (find) query. You can then also use the include of your find query.

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.