Troubleshooting column at parse.com

My goal is to clear the pointer column of the parse object:

var query = new Parse.Query("MyClass");
query.get("myobjectid").then(function(o) {
    o.pointerColumn = undefined;
    return o.save();
}).then(function() {
    var query2 = new Parse.Query("MyClass");
    return query2.get("myobjectid");
}).then(function(o) {
    alert(o.pointerColumn);
});

      

The warning (and the data browser) shows me that the column value still exists. Am I going about this wrong?

+3


source to share


2 answers


It turns out Parse.Object provides a method called unset

to make a column value undefined. My code, rewritten to work, looks like this:



var query = new Parse.Query("MyClass");
query.get("myobjectid").then(function(o) {
    o.unset("pointerColumn");
    return o.save();
}).then(function() {
    var query2 = new Parse.Query("MyClass");
    return query2.get("myobjectid");
}).then(function(o) {
    alert(o.pointerColumn);  // alerts undefined, as expected
});

      

+6


source


This line sets the property value undefined

just like any other assignment operator will set the value.

o.pointerColumn = undefined;

      



Use instead delete

to completely remove a property from an object o

:

delete o.pointerColumn;
return o.save();

      

+1


source







All Articles