解析服务器Javascript API发布到指针

问题描述 投票:1回答:2

我的Parse Server上有一个指针字段。我正在尝试使用Javascript API在指针中编写链接类字段的objectId。这是我的功能:

  $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();
};

ACL和QTY字段(数字)写入数据库没有问题,但指针字段(名为“shop”)不会填充。

javascript angularjs parse-platform parse-server
2个回答
1
投票

不要'代表'你认为指针应该是什么样的代码,使用sdk为你做!

var shop = new ParseObject('Shop');
shop.id = 'dklJ4Oaf2B';
var newII = new Item();
newII.set('shop', shop);
newII.save()

0
投票

你可以简单地使用newII.set('shop', new Parse.Object('shop').createWithoutData('dklJ4Oaf2B'); http://docs.parseplatform.org/js/guide/#data-types

© www.soinside.com 2019 - 2024. All rights reserved.