2017-09-22 74 views
0

問題描述解析服務器relation.add()不工作

如果我創建的關係,並使用它沒有任何反應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

insted的的

relation.add(invites) 

請嘗試以下

for (var i =0; i<invites.length;i++){ 
    relation.add(invites[i]) 
    } 

問候