API Docs for:

Class Parse.Cloud

Contains functions for calling and declaring cloud functions.

Some functions are only available from Cloud Code.

afterDelete( arg1, func )

Registers an after delete function.

Available in Cloud Code only.

If you want to use afterDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

  Parse.Cloud.afterDelete('MyCustomClass', function(request) {
    // code here
  })

  Parse.Cloud.afterDelete(Parse.User, function(request) {
    // code here
  })
Parameters:
  • arg1 <Class>

    The Parse.Object subclass to register the before save function for. This can instead be a String that is the className of the subclass.

  • func <Function>

    The function to run before a save. This function should take just one parameter, {@link Parse.Cloud.AfterDeleteRequest}.

afterSave( arg1, func )

Registers an after save function.

Available in Cloud Code only.

If you want to use afterSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
  Parse.Cloud.afterSave('MyCustomClass', function(request) {
    // code here
  })

  Parse.Cloud.afterSave(Parse.User, function(request) {
    // code here
  })
Parameters:
  • arg1 <Class>

    The Parse.Object subclass to register the before save function for. This can instead be a String that is the className of the subclass.

  • func <Function>

    The function to run before a save. This function should take just one parameter, {@link Parse.Cloud.AfterSaveRequest}.

beforeDelete( arg1, func )

Registers a before delete function.

Available in Cloud Code only.

If you want use beforeDelete for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.

  Parse.Cloud.beforeDelete('MyCustomClass', function(request, response) {
    // code here
  })

  Parse.Cloud.beforeDelete(Parse.User, function(request, response) {
    // code here
  })
Parameters:
  • arg1 <Class>

    The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass.

  • func <Function>

    The function to run before a delete. This function should take two parameters a {@link Parse.Cloud.BeforeDeleteRequest} and a {@link Parse.Cloud.BeforeDeleteResponse}

beforeSave( arg1, func )

Registers a before save function.

Available in Cloud Code only.

If you want use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. {@link Parse.User}), you should pass the class itself and not the String for arg1.
  Parse.Cloud.beforeSave('MyCustomClass', function(request, response) {
    // code here
  })

  Parse.Cloud.beforeSave(Parse.User, function(request, response) {
    // code here
  })
Parameters:
  • arg1 <Class>

    The Parse.Object subclass to register the before save function for. This can instead be a String that is the className of the subclass.

  • func <Function>

    The function to run before a save. This function should take two parameters a {@link Parse.Cloud.BeforeSaveRequest} and a {@link Parse.Cloud.BeforeSaveResponse}

define( name, func )

Defines a Cloud Function.

Available in Cloud Code only.

Parameters:
  • name <String>

    The name of the Cloud Function

  • func <Function>

    The Cloud Function to register. This function should take two parameters a Parse.Cloud.FunctionRequest and a Parse.Cloud.FunctionResponse

Parse.Promise httpRequest( options )

Makes an HTTP Request.

Available in Cloud Code only.

There is a limit of 8 concurrent httpRequests per Cloud Code request, and additional requests will be queued up. If your url specifies a port number, it must be 80, 443, or any number from 1025 through 65535.

By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the {@link Parse.Cloud.HTTPOptions} object to change this behavior.

Sample request:

  Parse.Cloud.httpRequest({
    url: 'http://www.parse.com/'
  }).then(function(httpResponse) {
    // success
    console.log(httpResponse.text);
  },function(httpResponse) {
    // error
    console.error('Request failed with response code ' + httpResponse.status);
  });
Parameters:
  • options <HTTPOptions>

    The Parse.Cloud.HTTPOptions object that makes the request.


Returns: <Parse.Promise>

A promise that will be resolved with a Parse.Cloud.HTTPResponse object when the request completes.

job( name, func )

Defines a Background Job.

Available in Cloud Code only.

Parameters:
  • name <String>

    The name of the Background Job

  • func <Function>

    The Background Job to register. This function should take two parameters a {@link Parse.Cloud.JobRequest} and a {@link Parse.Cloud.JobStatus}

Parse.Promise run( name, data, options )

Makes a call to a cloud function.

Parameters:
  • name <String>

    The function name.

  • data <Object>

    The parameters to send to the cloud function.

  • options <Object>

    A Backbone-style options object options.success, if set, should be a function to handle a successful call to a cloud function. options.error should be a function that handles an error running the cloud function. Both functions are optional. Both functions take a single argument.


Returns: <Parse.Promise>

A promise that will be resolved with the result of the function.

useMasterKey( )

Switches the Parse SDK to using the Master key. The Master key grants priveleged access to the data in Parse and can be used to bypass ACLs and other restrictions that are applied to the client SDKs.

Available in Cloud Code and Node.js only.