parse-dashboard 5.2.0-alpha.18 → 5.2.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -42,6 +42,7 @@ Parse Dashboard is a standalone dashboard for managing your [Parse Server](https
|
|
|
42
42
|
- [Other Configuration Options](#other-configuration-options)
|
|
43
43
|
- [Prevent columns sorting](#prevent-columns-sorting)
|
|
44
44
|
- [Custom order in the filter popup](#custom-order-in-the-filter-popup)
|
|
45
|
+
- [Scripts](#scripts)
|
|
45
46
|
- [Running as Express Middleware](#running-as-express-middleware)
|
|
46
47
|
- [Deploying Parse Dashboard](#deploying-parse-dashboard)
|
|
47
48
|
- [Preparing for Deployment](#preparing-for-deployment)
|
|
@@ -362,6 +363,71 @@ For example:
|
|
|
362
363
|
|
|
363
364
|
You can conveniently create a filter definition without having to write it by hand by first saving a filter in the data browser, then exporting the filter definition under *App Settings > Export Class Preferences*.
|
|
364
365
|
|
|
366
|
+
### Scripts
|
|
367
|
+
|
|
368
|
+
You can specify scripts to execute Cloud Functions with the `scripts` option:
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
```json
|
|
372
|
+
"apps": [
|
|
373
|
+
{
|
|
374
|
+
"scripts": [
|
|
375
|
+
{
|
|
376
|
+
"title": "Delete Account",
|
|
377
|
+
"classes": ["_User"],
|
|
378
|
+
"cloudCodeFunction": "deleteAccount"
|
|
379
|
+
}
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
]
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Next, define the Cloud Function in Parse Server that will be called. The object that has been selected in the data browser will be made available as a request parameter:
|
|
386
|
+
|
|
387
|
+
```js
|
|
388
|
+
Parse.Cloud.define('deleteAccount', async (req) => {
|
|
389
|
+
req.params.object.set('deleted', true);
|
|
390
|
+
await req.params.object.save(null, {useMasterKey: true});
|
|
391
|
+
}, {
|
|
392
|
+
requireMaster: true
|
|
393
|
+
});
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
⚠️ Depending on your Parse Server version you may need to set the Parse Server option `encodeParseObjectInCloudFunction` to `true` so that the selected object in the data browser is made available in the Cloud Function as an instance of `Parse.Object`. If the option is not set, is set to `false`, or you are using an older version of Parse Server, the object is made available as a plain JavaScript object and needs to be converted from a JSON object to a `Parse.Object` instance with `req.params.object = Parse.Object.fromJSON(req.params.object);`, before you can call any `Parse.Object` properties and methods on it.
|
|
397
|
+
|
|
398
|
+
For older versions of Parse Server:
|
|
399
|
+
|
|
400
|
+
<details>
|
|
401
|
+
<summary>Parse Server >=4.4.0 <6.2.0</summary>
|
|
402
|
+
|
|
403
|
+
```js
|
|
404
|
+
Parse.Cloud.define('deleteAccount', async (req) => {
|
|
405
|
+
req.params.object = Parse.Object.fromJSON(req.params.object);
|
|
406
|
+
req.params.object.set('deleted', true);
|
|
407
|
+
await req.params.object.save(null, {useMasterKey: true});
|
|
408
|
+
}, {
|
|
409
|
+
requireMaster: true
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
</details>
|
|
414
|
+
|
|
415
|
+
<details>
|
|
416
|
+
<summary>Parse Server >=2.1.4 <4.4.0</summary>
|
|
417
|
+
|
|
418
|
+
```js
|
|
419
|
+
Parse.Cloud.define('deleteAccount', async (req) => {
|
|
420
|
+
if (!req.master || !req.params.object) {
|
|
421
|
+
throw 'Unauthorized';
|
|
422
|
+
}
|
|
423
|
+
req.params.object = Parse.Object.fromJSON(req.params.object);
|
|
424
|
+
req.params.object.set('deleted', true);
|
|
425
|
+
await req.params.object.save(null, {useMasterKey: true});
|
|
426
|
+
});
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
</details>
|
|
430
|
+
|
|
365
431
|
# Running as Express Middleware
|
|
366
432
|
|
|
367
433
|
Instead of starting Parse Dashboard with the CLI, you can also run it as an [express](https://github.com/expressjs/express) middleware.
|