Parse. Cloud

The Parse Cloud Code SDK.

Interfaces

AfterFindRequest
BeforeFindRequest
ConnectTriggerRequest
FileTriggerRequest
FunctionRequest
JobRequest
LiveQueryEventTrigger
TriggerRequest
ValidatorObject

Methods

(static) afterDelete(arg1, func, validator)

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. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.afterDelete('MyCustomClass', async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterDelete(Parse.User, async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run after a delete. This function can be async and should take just one parameter, Parse.Cloud.TriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.TriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) afterDeleteFile(func, validator)

Registers an after delete file function.

Available in Cloud Code only.

Parse.Cloud.afterDeleteFile(async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterDeleteFile(async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
funcfunction

The function to after before deleting a file. This function can be async and should take just one parameter, Parse.Cloud.FileTriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.FileTriggerRequest, or a Parse.Cloud.ValidatorObject.

Deprecated
  • Yes

(static) afterFind(arg1, func, validator)

Registers an after find function.

Available in Cloud Code only.

If you want to use afterFind for a predefined class in the Parse JavaScript SDK (e.g. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.afterFind('MyCustomClass', async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterFind(Parse.User, async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run before a find. This function can be async and should take just one parameter, Parse.Cloud.AfterFindRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.AfterFindRequest, or a Parse.Cloud.ValidatorObject.

(static) afterLiveQueryEvent(arg1, func, validator)

Registers an after live query server event function.

Available in Cloud Code only.

Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterLiveQueryEvent('MyCustomClass', (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

The Parse.Object subclass to register the after live query event function for. This can instead be a String that is the className of the subclass.

funcfunction

The function to run after a live query event. This function can be async and should take one parameter, a Parse.Cloud.LiveQueryEventTrigger.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.LiveQueryEventTrigger, or a Parse.Cloud.ValidatorObject.

(static) afterLogin(func)

Registers the after login function.

Available in Cloud Code only.

This function is triggered after a user logs in successfully, and after a _Session object has been created.

Parse.Cloud.afterLogin((request) => {
  // code here
});
Parameters:
NameTypeDescription
funcfunction

The function to run after a login. This function can be async and should take one parameter a Parse.Cloud.TriggerRequest;

(static) afterLogout(func)

Registers the after logout function.

Available in Cloud Code only.

This function is triggered after a user logs out.

Parse.Cloud.afterLogout((request) => {
  // code here
});
Parameters:
NameTypeDescription
funcfunction

The function to run after a logout. This function can be async and should take one parameter a Parse.Cloud.TriggerRequest;

(static) afterSave(arg1, func, validator)

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. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.afterSave('MyCustomClass', async function(request) {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterSave(Parse.User, async function(request) {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run after a save. This function can be an async function and should take just one parameter, Parse.Cloud.TriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.TriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) afterSaveFile(func, validator)

Registers an after save file function.

Available in Cloud Code only.

Parse.Cloud.afterSaveFile(async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.afterSaveFile(async (request) => {
 // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
funcfunction

The function to run after saving a file. This function can be async and should take just one parameter, Parse.Cloud.FileTriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.FileTriggerRequest, or a Parse.Cloud.ValidatorObject.

Deprecated
  • Yes

(static) beforeConnect(func, validator)

Registers a before live query server connect function.

Available in Cloud Code only.

Parse.Cloud.beforeConnect(async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeConnect(async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
funcfunction

The function to before connection is made. This function can be async and should take just one parameter, Parse.Cloud.ConnectTriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.ConnectTriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) beforeDelete(arg1, func, validator)

Registers a before delete function.

Available in Cloud Code only.

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

Parse.Cloud.beforeDelete('MyCustomClass', (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeDelete(Parse.User, (request) => {
  // code here
}, { ...validationObject })
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run before a delete. This function can be async and should take one parameter, a Parse.Cloud.TriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.TriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) beforeDeleteFile(func, validator)

Registers a before delete file function.

Available in Cloud Code only.

Parse.Cloud.beforeDeleteFile(async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeDeleteFile(async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
funcfunction

The function to run before deleting a file. This function can be async and should take just one parameter, Parse.Cloud.FileTriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.FileTriggerRequest, or a Parse.Cloud.ValidatorObject.

Deprecated
  • Yes

(static) beforeFind(arg1, func, validator)

Registers a before find function.

Available in Cloud Code only.

If you want to use beforeFind for a predefined class in the Parse JavaScript SDK (e.g. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.beforeFind('MyCustomClass', async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeFind(Parse.User, async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run before a find. This function can be async and should take just one parameter, Parse.Cloud.BeforeFindRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.BeforeFindRequest, or a Parse.Cloud.ValidatorObject.

(static) beforeLogin(func)

Registers the before login function.

Available in Cloud Code only.

This function provides further control in validating a login attempt. Specifically, it is triggered after a user enters correct credentials (or other valid authData), but prior to a session being generated.

Parse.Cloud.beforeLogin((request) => {
  // code here
})

Parameters:
NameTypeDescription
funcfunction

The function to run before a login. This function can be async and should take one parameter a Parse.Cloud.TriggerRequest;

(static) beforeSave(arg1, func, validator)

Registers a before save function.

Available in Cloud Code only.

If you want to use beforeSave for a predefined class in the Parse JavaScript SDK (e.g. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.beforeSave('MyCustomClass', (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeSave(Parse.User, (request) => {
  // code here
}, { ...validationObject })
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run before a save. This function can be async and should take one parameter a Parse.Cloud.TriggerRequest;

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.TriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) beforeSaveFile(func, validator)

Registers a before save file function.

Available in Cloud Code only.

Parse.Cloud.beforeSaveFile(async (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeSaveFile(async (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
funcfunction

The function to run before saving a file. This function can be async and should take just one parameter, Parse.Cloud.FileTriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.FileTriggerRequest, or a Parse.Cloud.ValidatorObject.

Deprecated
  • Yes

(static) beforeSubscribe(arg1, func, validator)

Registers a before live query subscription function.

Available in Cloud Code only.

If you want to use beforeSubscribe for a predefined class in the Parse JavaScript SDK (e.g. Parse.User or Parse.File), you should pass the class itself and not the String for arg1.

Parse.Cloud.beforeSubscribe('MyCustomClass', (request) => {
  // code here
}, (request) => {
  // validation code here
});

Parse.Cloud.beforeSubscribe(Parse.User, (request) => {
  // code here
}, { ...validationObject });
Parameters:
NameTypeDescription
arg1String | Parse.Object

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

funcfunction

The function to run before a subscription. This function can be async and should take one parameter, a Parse.Cloud.TriggerRequest.

validatorObject | function

An optional function to help validating cloud code. This function can be an async function and should take one parameter a Parse.Cloud.TriggerRequest, or a Parse.Cloud.ValidatorObject.

(static) job(name, func)

Defines a Background Job.

Available in Cloud Code only.

Parameters:
NameTypeDescription
nameString

The name of the Background Job

funcfunction

The Background Job to register. This function can be async should take a single parameters a Parse.Cloud.JobRequest

(static) sendEmail(data)

Sends an email through the Parse Server mail adapter.

Available in Cloud Code only. Requires a mail adapter to be configured for Parse Server.

Parse.Cloud.sendEmail({
  from: 'Example <[email protected]>',
  to: '[email protected]',
  subject: 'Test email',
  text: 'This email is a test.'
});
Parameters:
NameTypeDescription
dataObject

The object of the mail data to send.