问题说明
如果我创建一个关系并使用relation.add()方法就没有任何反应。
重现的步骤
let Booking = Parse.Object.extend("Booking")
let bookingQuery = new Parse.Query(Booking)
bookingQuery.get(newBookingObject.id, {
success: booking => {
console.log("invites", invites)
// prints array of existing ParseObjects from another class
let relation = booking.relation("invites")
console.log(relation)
// prints new relation with key "invites" and parent "Booking"
relation.add(invites)
console.log(relation)
// prints exactly the same relation object as before - nothing changed
booking.save().then(res => console.log(res))
// an empty relation is added
},
error: error => console.log("error", error)
// no errors
})
预期结果
relation.add(arrayOfParseObjects)应该将对象添加到关系
实际结果
什么都没发生
答案 0 :(得分:0)
insted of
relation.add(invites)
请尝试以下
for (var i =0; i<invites.length;i++){
relation.add(invites[i])
}
此致