How do I remove a column from a class?

At Parse.com, there is a way to remove a column from a class in the web interface.

Inside the core of x data โ†’ Advanced โ†’ Delete column .

Is there a way to accomplish the same operation in Cloud code ?

+3


source to share


2 answers


As far as this thread is concerned, you can't do it without a hack or two.



https://www.parse.com/questions/is-there-any-way-to-drop-and-add-a-column-in-a-class-table-with-cloud-code

+1


source


You can do this using the REST API, but unfortunately not directly using CloudCode ... It's not just its functionality, which is only available in the REST API. But this can be a slightly more tedious method than you might like ...

Make a call from your cloud code back to your own backend ... You can find how to make a REST call from your cloud code from http://parseplatform.github.io/docs/cloudcode/guide/#networking something like this. of course you will need to add your own urls, parameters and headers, and I'm not sure, but you might need to authenticate with a master key

Parse.Cloud.httpRequest({
  url: 'http://www.example.com/',`enter code here`
  headers: {
    'Content-Type': 'application/json;charset=utf-8'
  }
}).then(function(httpResponse) {
  console.log(httpResponse.text);
}, function(httpResponse) {
  console.error('Request failed with response code ' + httpResponse.status);
});

      



See this link under Modifying Schema: http://parseplatform.github.io/docs/rest/guide/#modifying-the-schema

the following parameters are also sent from the dashboard request to the body of the "PUT" request:

{
"className": "<CLASSNAME>,
"fields":
        {
        "<FIELDNAM>]":{
                       "__op":"Delete"
                      }
        },
"_method":"PUT",
"_ApplicationId":"<APPLICATIONID>",
"_ClientVersion":"js1.6.14",
"_MasterKey":"<MASTERKEY>",
"_InstallationId":"<INSTALLATIONID>"
}

      

+1


source







All Articles