【发布时间】:2015-09-18 22:19:52
【问题描述】:
我已经保存了 myreferenceobject 并且在 sucess 函数中,我试图运行一个循环并创建许多其他对象,保存为与引用对象的“关系”。
// already have a reference to myreferenceobject
myobject.set("Name", artists_input["Name"]);
myobject.set("JbId", 12334);
myobject.save(null, {
success: function(myobject) {
console.log('New object created with objectId: ' + artist.id);
var relation = myreferenceobject.relation("Objects");
relation.add(myobject);
myreferenceobject.save();
},
error: function(myobject, error) {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
console.log('Failed to create new myobject, with error code: ' + error.message);
}
});
当我运行脚本时,我收到以下错误
ReferenceError: parent is not defined
at ParseRelation.add
/home/myapp/node_modules/parse/lib/node/ParseRelation.js:102
return parent;
^
我遵循了 parse 提供的语法,但我仍然收到此错误
有什么想法吗?
这是一个更简单的例子,但也失败了
var TestObject = Parse.Object.extend("TestObject");
var testObject = new TestObject();
testObject.set("Name", "testName");
testObject.save(null, {
success: function(testObject) {
// Execute any logic that should take place after the object is saved.
console.log('New testObject created with objectId: ' + testObject.id);
var TestObject2 = Parse.Object.extend("TestObject2");
var testObject2 = new TestObject2();
testObject2.set("Name", "testName2");
testObject2.save(null, {
success: function(testObject2) {
// Execute any logic that should take place after the object is saved.
console.log('New testObject2 created with objectId: ' + testObject2.id);
var relation = testObject.relation("TestObjectRelation");
console.log('Make sure the relation exists ' + testObject.relation("TestObjectRelation"));
relation.add(testObject2);
testObject.save();
},
error: function(testObject2, error) {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
console.log('Failed to create new testObject2, with error code: ' + error.message);
}
});
},
error: function(venue, error) {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
console.log('Failed to create new testObject, with error code: ' + error.message);
}
});
【问题讨论】:
-
如果
myreferenceobject没有名为“对象”的列,我希望看到这个 -
不是这样的,确实有专栏,我搜过看到有人抱怨在python sdk中有类似的...专栏是def那里
-
你能把myObject、myreferenceobject 和artist 的全部历史贴出来吗?每个是如何创建的?我对已构建但尚未保存的对象特别感兴趣。
-
@danh ...你要求它,我发布了代码,但我意识到它非常令人困惑我试图也描述逻辑
标签: node.js parse-platform relation