1

I have a pointer field in my class on my Parse Server. I am trying to use the Javascript API to write the objectId of a linked class field in a Pointer. Here is my function:

  $scope.createItem = function (user, product) {
        var Item = Parse.Object.extend("II"),newII = new Item();
        newII.set("product", product);
        var acl = new Parse.ACL();
        acl.setPublicReadAccess(false);
        acl.setPublicWriteAccess(false);
        acl.setReadAccess(Parse.User.current(), true);
        acl.setWriteAccess(Parse.User.current(), true);
        // This doesn't work
        newII.set({
            "__type": "Pointer",
            "shop": "dklJ4Oaf2B"
        });
        newII.set("QTY", $scope.qtyCount);
        newII.save();
};

The ACL & QTY fields (number) write to the database without issue, however the pointer field (named "shop") doesn't populate.

2 Answers 2

1

Don't 'hand' code what you think a pointer should look like, use the sdk to do it for you!

var shop = new ParseObject('Shop');
shop.id = 'dklJ4Oaf2B';
var newII = new Item();
newII.set('shop', shop);
newII.save()
Sign up to request clarification or add additional context in comments.

Comments

0

You can simply use newII.set('shop', new Parse.Object('shop').createWithoutData('dklJ4Oaf2B'); http://docs.parseplatform.org/js/guide/#data-types

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.