我在名为 lastDrive
的列中有一个来自类 Drives
的名为 thisDrive
的模型的关系,它也是一个 驱动
。有时我需要删除这个关系,所以没有任何关系(未定义)。如何在不删除的情况下从单个驱动器中删除关系。
这是我试过的。
var thisDrive = app.drivesCollection.model[0];
var relation = thisDrive.attributes.lastDrive.relation('lastDrive'); // I'm not sure about this line here....
relation.remove('lastDrive'); // not sure again...
此时我希望 thisDrive.attributes.lastDrive
为空,但它不是...
如果我运行 thisDrive.attributes.lastDrive.remove()
,我将删除此关系引用的 Drive
... 这很糟糕。
知道如何实现吗?
谢谢。
最佳答案
我个人不会将列值设置为空。最初的空列是 (undefines)。它们对应于 iOS 中的 nil。如果您将一列设置为 null,它将返回一个不再为 nil 的 NSNull 对象。
要删除关系,您可以取消设置列并保存。
user.unset("registrationVoucher");
user.save();
关于javascript - 如何在不删除相关对象的情况下删除 Parse.Object 中的关系(指针)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25879403/