2014-09-16 6 views
4

나는 DrivelastDrive이라는 열에 Drives이라는 thisDrive 모델과 관계가 있습니다. 때로는이 관계를 삭제해야하므로 아무 것도 관련되지 않습니다 (정의되지 않음). 하나의 드라이브에서 관계를 삭제하지 않고 어떻게 제거 할 수 있습니까? 여기관련 객체를 삭제하지 않고 Parse.Object에서 관계 (포인터)를 제거하는 방법은 무엇입니까?

enter image description here

내가 뭘하려합니다.

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을 제거합니다 ... 이는 나쁜 .

어떻게하면 좋을까요?

감사합니다.

답변

4

당신이해야 할 일은 객체의 속성을 null로 설정 한 다음 저장하는 것입니다.

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

나는 "정의"를 시도했지만 작동하지 않았다. 'null'이 트릭을했습니다. 감사! – otmezger

5

저는 개인적으로 열 값을 null로 설정하지 않습니다. 원래 빈 열은 (undefines)입니다. 이것은 iOS의 nil에 해당합니다. 열을 null로 설정하면 더 이상 NSNull 객체가 반환되지 않습니다.

관계를 제거하려면 열을 설정 해제하고 저장할 수 있습니다.

user.unset("registrationVoucher"); 
user.save(); 
0

는 목적-C 버전

 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"); 
        } 
       }];