The Parse Cloud Code SDK.
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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run after a delete. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to after before deleting a file. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run before a find. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run after a live query event. This function can be async and should take one parameter, a |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run after a login. This function can be async and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run after a logout. This function can be async and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run after a save. This function can be an async function and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run after saving a file. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to before connection is made. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run before a delete. This function can be async and should take one parameter, a |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run before deleting a file. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run before a find. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run before a login. This function can be async and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run before a save. This function can be async and should take one parameter a |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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:
Name | Type | Description |
---|---|---|
func |
function
|
The function to run before saving a file. This function can be async and should take just one parameter, |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(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
), 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:
Name | Type | Description |
---|---|---|
arg1 |
String
|
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. |
func |
function
|
The function to run before a subscription. This function can be async and should take one parameter, a |
validator |
Object
|
function
|
An optional function to help validating cloud code. This function can be an async function and should take one parameter a |
(static) httpRequest(options) → {Promise.<Parse.Cloud.HTTPResponse>}
Makes an HTTP Request.
Available in Cloud Code only.
By default, Parse.Cloud.httpRequest does not follow redirects caused by HTTP 3xx response codes. You can use the followRedirects option in the 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:
Name | Type | Description |
---|---|---|
options |
Parse.Cloud.HTTPOptions
|
The Parse.Cloud.HTTPOptions object that makes the request. |
Returns:
- Type:
-
Promise.<Parse.Cloud.HTTPResponse>
A promise that will be resolved with a Parse.Cloud.HTTPResponse
object when the request completes.
(static) job(name, func)
Defines a Background Job.
Available in Cloud Code only.
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The name of the Background Job |
func |
function
|
The Background Job to register. This function can be async should take a single parameters a |
(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:
Name | Type | Description |
---|---|---|
data |
Object
|
The object of the mail data to send. |
Type Definitions
HTTPOptions
Properties:
Name | Type | Description |
---|---|---|
body |
String
|
Object
|
The body of the request. If it is a JSON object, then the Content-Type set in the headers must be application/x-www-form-urlencoded or application/json. You can also set this to a |
error |
function
|
The function that is called when the request fails. It will be passed a Parse.Cloud.HTTPResponse object. |
followRedirects |
Boolean
|
Whether to follow redirects caused by HTTP 3xx responses. Defaults to false. |
headers |
Object
|
The headers for the request. |
method |
String
|
The method of the request. GET, POST, PUT, DELETE, HEAD, and OPTIONS are supported. Will default to GET if not specified. |
params |
String
|
Object
|
The query portion of the url. You can pass a JSON object of key value pairs like params: {q : 'Sean Plott'} or a raw string like params:q=Sean Plott. |
success |
function
|
The function that is called when the request successfully completes. It will be passed a Parse.Cloud.HTTPResponse object. |
url |
string
|
The url to send the request to. |
HTTPResponse
Properties:
Name | Type | Description |
---|---|---|
buffer |
Buffer
|
The raw byte representation of the response body. Use this to receive binary data. See Buffer for more details. |
cookies |
Object
|
The cookies sent by the server. The keys in this object are the names of the cookies. The values are Parse.Cloud.Cookie objects. |
data |
Object
|
The parsed response body as a JavaScript object. This is only available when the response Content-Type is application/x-www-form-urlencoded or application/json. |
headers |
Object
|
The headers sent by the server. The keys in this object are the names of the headers. We do not support multiple response headers with the same name. In the common case of Set-Cookie headers, please use the cookies field instead. |
status |
Number
|
The status code. |
text |
String
|
The raw text representation of the response body. |