【问题标题】:Parse Server relation.add() not working解析服务器relation.add()不起作用
【发布时间】:2017-09-22 03:56:12
【问题描述】:

问题描述

如果我创建一个关系并在其上使用 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) 应该将对象添加到关系中

实际结果

什么都没发生

【问题讨论】:

    标签: parse-platform add parse-server relation


    【解决方案1】:

    插入

        relation.add(invites)
    

    请尝试以下方法

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

    问候

    【讨论】:

      猜你喜欢
      • 2016-08-22
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      • 2016-12-12
      • 2016-02-02
      • 1970-01-01
      • 2012-08-06
      • 1970-01-01
      相关资源
      最近更新 更多