How to delete a relation (pointer) in Parse.Object without deleting the related object?

I have a relationship from a model called a thisDriveclass Drivesin a column with a name lastDrivethat is also Drive. Sometimes I need to delete this relationship, so nothing is connected (undefined). How to remove a relationship from one drive without deleting.

enter image description here

this 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 it to thisDrive.attributes.lastDrivebe empty, but that is not ...

If I run thisDrive.attributes.lastDrive.remove(), I will delete the Drivelink this link refers to ... which is bad.

any idea how to achieve this?

Thank.

+4
source share
3 answers

, object null, .

var thisDrive = app.drivesCollection.model[0];
thisDrive.set("lastDrive", null);
thisDrive.save();
+4

. (undefines). nil iOS. , NSNull, nil.

, .

user.unset("registrationVoucher");
user.save();
+5

OBJECTIVE-C VERSION

     PFQuery *query = [PFQuery queryWithClassName:@"yourClassName"];
                [query getObjectInBackgroundWithId:@"yourObjectId" block:^(PFObject *objConsult, NSError *error) {

                    if (!error) {
                        [objConsult removeObjectForKey:@"yourPointerKey"];
                        SDCommonService *commonService = [SDCommonService new];
                        [commonService saveIntoParse:objConsult andPinName:nil
                                     withDescription:@"text"
                                                    :^(id objectId) {
                                                        NSLog(@"%@",objectId);


                                                    }];

                    }
                    else{

                        NSLog(@"ERROR");
                    }
                }];
0
source

All Articles