Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove a relation (pointer) in a Parse.Object without deleting the related Object?

I have a relation from the a model called thisDrive of class Drives in a column called lastDrive, which is also a Drive. Sometimes I need to delete this relation, so nothing is related (undefined). How can I remove the relation from a single drive without deleting.

enter image description here

here is what I tried.

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... 

at this point I would expect thisDrive.attributes.lastDrive to be empty, but it is not...

if I run thisDrive.attributes.lastDrive.remove() I will remove the Drive that is referenced by this relationship... which is bad.

any idea how to achieve this?

Thanks.

like image 227
otmezger Avatar asked Jan 09 '23 19:01

otmezger


1 Answers

I personally do not set column values to null. Originally empty columns are (undefines).Those correspond to nil in iOS. If you set a column to null that would return you an NSNull object not nil anymore.

In order to remove a relation you can unset the column and save.

user.unset("registrationVoucher");
user.save();
like image 61
Ilker Baltaci Avatar answered Jan 12 '23 07:01

Ilker Baltaci