|
2 | 2 | * Defines a Cloud Function.
|
3 | 3 | *
|
4 | 4 | * **Available in Cloud Code only.**
|
| 5 | + * **Starting parse-server 3.0.0, all cloud hooks and functions are asynchronous** |
| 6 | + * **All response objects are removed and replaced by promises / async/await based resolution** |
5 | 7 | *
|
6 | 8 | * @method define
|
7 | 9 | * @name Parse.Cloud.define
|
8 | 10 | * @param {String} name The name of the Cloud Function
|
9 |
| - * @param {Function} data The Cloud Function to register. This function should take two parameters a {@link Parse.Cloud.FunctionRequest} and a {@link Parse.Cloud.FunctionResponse} |
| 11 | + * @param {Function} data The Cloud Function to register. This function can be an async function and should take one parameter a {@link Parse.Cloud.FunctionRequest}. |
10 | 12 | */
|
11 | 13 |
|
12 | 14 | /**
|
|
16 | 18 | *
|
17 | 19 | * 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.
|
18 | 20 | * ```
|
19 |
| - * Parse.Cloud.afterDelete('MyCustomClass', (request) => { |
| 21 | + * Parse.Cloud.afterDelete('MyCustomClass', async (request) => { |
20 | 22 | * // code here
|
21 | 23 | * })
|
22 | 24 | *
|
23 |
| - * Parse.Cloud.afterDelete(Parse.User, (request) => { |
| 25 | + * Parse.Cloud.afterDelete(Parse.User, async (request) => { |
24 | 26 | * // code here
|
25 | 27 | * })
|
26 | 28 | *```
|
27 | 29 | *
|
28 | 30 | * @method afterDelete
|
29 | 31 | * @name Parse.Cloud.afterDelete
|
30 | 32 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after delete function for. This can instead be a String that is the className of the subclass.
|
31 |
| - * @param {Function} func The function to run after a delete. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
| 33 | + * @param {Function} func The function to run after a delete. This function can be async and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
32 | 34 | */
|
33 | 35 |
|
34 | 36 | /**
|
|
40 | 42 | * 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.
|
41 | 43 | *
|
42 | 44 | * ```
|
43 |
| - * Parse.Cloud.afterSave('MyCustomClass', function(request) { |
| 45 | + * Parse.Cloud.afterSave('MyCustomClass', async function(request) { |
44 | 46 | * // code here
|
45 | 47 | * })
|
46 | 48 | *
|
47 |
| - * Parse.Cloud.afterSave(Parse.User, function(request) { |
| 49 | + * Parse.Cloud.afterSave(Parse.User, async function(request) { |
48 | 50 | * // code here
|
49 | 51 | * })
|
50 | 52 | * ```
|
51 | 53 | *
|
52 | 54 | * @method afterSave
|
53 | 55 | * @name Parse.Cloud.afterSave
|
54 | 56 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
|
55 |
| - * @param {Function} func The function to run after a save. This function should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
| 57 | + * @param {Function} func The function to run after a save. This function can be an async function and should take just one parameter, {@link Parse.Cloud.TriggerRequest}. |
56 | 58 | */
|
57 | 59 |
|
58 | 60 | /**
|
|
62 | 64 | *
|
63 | 65 | * If you want to 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.
|
64 | 66 | * ```
|
65 |
| - * Parse.Cloud.beforeDelete('MyCustomClass', (request, response) => { |
| 67 | + * Parse.Cloud.beforeDelete('MyCustomClass', (request) => { |
66 | 68 | * // code here
|
67 | 69 | * })
|
68 | 70 | *
|
69 |
| - * Parse.Cloud.beforeDelete(Parse.User, (request, response) => { |
| 71 | + * Parse.Cloud.beforeDelete(Parse.User, (request) => { |
70 | 72 | * // code here
|
71 | 73 | * })
|
72 | 74 | *```
|
73 | 75 | *
|
74 | 76 | * @method beforeDelete
|
75 | 77 | * @name Parse.Cloud.beforeDelete
|
76 | 78 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the before delete function for. This can instead be a String that is the className of the subclass.
|
77 |
| - * @param {Function} func The function to run before a delete. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeDeleteResponse}. |
| 79 | + * @param {Function} func The function to run before a delete. This function can be async and should take one parameter, a {@link Parse.Cloud.TriggerRequest}. |
78 | 80 | */
|
79 | 81 |
|
80 | 82 | /**
|
|
86 | 88 | * If you want to 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.
|
87 | 89 | *
|
88 | 90 | * ```
|
89 |
| - * Parse.Cloud.beforeSave('MyCustomClass', (request, response) => { |
| 91 | + * Parse.Cloud.beforeSave('MyCustomClass', (request) => { |
90 | 92 | * // code here
|
91 | 93 | * })
|
92 | 94 | *
|
93 |
| - * Parse.Cloud.beforeSave(Parse.User, (request, response) => { |
| 95 | + * Parse.Cloud.beforeSave(Parse.User, (request) => { |
94 | 96 | * // code here
|
95 | 97 | * })
|
96 | 98 | * ```
|
97 | 99 | *
|
98 | 100 | * @method beforeSave
|
99 | 101 | * @name Parse.Cloud.beforeSave
|
100 | 102 | * @param {(String|Parse.Object)} arg1 The Parse.Object subclass to register the after save function for. This can instead be a String that is the className of the subclass.
|
101 |
| - * @param {Function} func The function to run before a save. This function should take two parameters a {@link Parse.Cloud.TriggerRequest} and a {@link Parse.Cloud.BeforeSaveResponse}. |
| 103 | + * @param {Function} func The function to run before a save. This function can be async and should take one parameter a {@link Parse.Cloud.TriggerRequest}; |
102 | 104 | */
|
103 | 105 |
|
104 | 106 | /**
|
|
135 | 137 | * @method job
|
136 | 138 | * @name Parse.Cloud.job
|
137 | 139 | * @param {String} name The name of the Background Job
|
138 |
| - * @param {Function} func The Background Job to register. This function should take two parameters a {@link Parse.Cloud.JobRequest} and a {@link Parse.Cloud.JobStatus} |
| 140 | + * @param {Function} func The Background Job to register. This function can be async should take a single parameters a {@link Parse.Cloud.JobRequest} |
139 | 141 | *
|
140 | 142 | */
|
141 | 143 |
|
|
163 | 165 | /**
|
164 | 166 | * @typedef Parse.Cloud.JobRequest
|
165 | 167 | * @property {Object} params The params passed to the background job.
|
166 |
| - */ |
167 |
| - |
168 |
| - /** |
169 |
| - * @typedef Parse.Cloud.JobStatus |
170 |
| - * @property {function} error If error is called, will end the job unsuccessfully with an optional completion message to be stored in the job status. |
171 | 168 | * @property {function} message If message is called with a string argument, will update the current message to be stored in the job status.
|
172 |
| - * @property {function} success If success is called, will end the job successfullly with the optional completion message to be stored in the job status. |
173 |
| - */ |
174 |
| - |
175 |
| -/** |
176 |
| - * @typedef Parse.Cloud.BeforeSaveResponse |
177 |
| - * @property {function} success If called, will allow the save to happen. If a Parse.Object is passed in, then the passed in object will be saved instead. |
178 |
| - * @property {function} error If called, will reject the save. An optional error message may be passed in. |
179 |
| - */ |
180 |
| - |
181 |
| -/** |
182 |
| - * @typedef Parse.Cloud.BeforeDeleteResponse |
183 |
| - * @property {function} success If called, will allow the delete to happen. |
184 |
| - * @property {function} error If called, will reject the save. An optional error message may be passed in. |
185 |
| - */ |
186 |
| - |
187 |
| -/** |
188 |
| - * @typedef Parse.Cloud.FunctionResponse |
189 |
| - * @property {function} success If success is called, will return a successful response with the optional argument to the caller. |
190 |
| - * @property {function} error If error is called, will return an error response with an optionally passed message. |
191 | 169 | */
|
192 | 170 |
|
193 | 171 | /**
|
|
0 commit comments