0

I've got a Class Users, which has a relation to a class Containers . I know an Id for the Container object, and i'm trying to figure out if the user has a specific container as a relation.

My code looks like this:

    Parse.User.currentAsync().then((myself) => {

        // create a relation based on the containers key
        var relation = myself.relation('containers');

        // generate a query based on that relation
        var query = relation.query();

        query.equalTo('id', oArgs.container.id);

        query.find().then((found) => {
            if (found.length > 1) {
                deferred.resolve(true);
            } else {
                deferred.resolve(false);
            }
        });

    });

I always get an empty set of results. Can anyone help me understand why, and explain what the correct way is of matching a specific object within a relation?

Thanks

1 Answer 1

1

Turns out that using

query.equalTo('id', oArgs.container.id);

does not work. Instead I used this:

query.equalTo('objectId', oArgs.container.id);

And it worked just fine.

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

1 Comment

Yes. The property is called objectId, but the JS SDK accessor is misleadingly called id. Also note, query.get(oArgs.container.id) is equivalent and a little more concise.

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.