0

Here is some Parse Cloud code I have running:

…….
var sentenceListQuery;
sentenceListQuery = new Parse.Query("SentenceList");
sentenceListQuery.equalTo("unit", request.params.unitID); // May be wrong!
sentenceListQuery.find
({…….});

unit is a column of type: Pointer

  • If I get rid of the line marked “May be wrong!”, by commenting it out, I get 83 as the number of rows found by the .find(), which is what I expect.

  • If I leave it there I get zero lines, which is not what I expect. I should get one line.

So my guess is that something is not right with the way I write the code on this line, but I don’t know what. Should I use a different syntax because it is a pointer? I found a few seemingly related things on the net, but nothing driving me to a working solution. Or would it be that relationships on Parse.com are more difficult to use than it should; and one should avoid using them? In fact getting the same result without relationships would be rather easy; I just thought it was better practice to use them.

1 Answer 1

1

You have to write a pointer as an object. Useful example:

 var unitPointer = {"__type":"Pointer","className":"Unit","objectId":request.params.unitID};    
 sentenceListQuery.equalTo("unit", unitPointer); // Should be right

The above example assumes the name of the Class you are pointing to is "Unit".

If applicable, you could replace your unitID parameter with some pointer in the request.object or request.user your Cloud Code is already processing.

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.