parse-community / parse-dashboard

A dashboard for managing Parse Server
https://parseplatform.org
Other
3.74k stars 1.38k forks source link

Pass selected field to Cloud Function script #2473

Closed mtrezza closed 1 year ago

mtrezza commented 1 year ago

New Feature / Enhancement Checklist

Current Limitation

Currently, it cannot be determined which field was been selected when a script has been invoked.

Feature / Enhancement Description

Pass the selected field as a separate parameter to the Cloud Function payload.

For example the dashboard user should be able to invoke a script on a user in a specific field of the selected object:

Knowing only the "transaction" object is not enough to know on which user the Cloud Function should be executed.

Example Use Case

Parse.Cloud.define('deleteUser', async (req) => {
  const selectedTransaction = req.params.object;
  selectedTransaction.set('invalid', true);
  await selectedTransaction.set.save(null, { useMasterKey: true });

  const selectedUser = req.params.selectedField;
  if (selectedUser instanceof Parse.User) {
    selectedUser.set('deleted', true);
    await selectedUser.save(null, { useMasterKey: true });
  }
});

Alternatives / Workarounds

None.

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

mtrezza commented 1 year ago

@dblythy What do you think?

dblythy commented 1 year ago

Sounds good

mtrezza commented 1 year ago

To avoid any confusion for future readers, in your PR you're passing the name of the selected field, instead of the value of the selected field as suggested in the example use case. I think that makes more sense, because if there are 2 fields of the same type with the same value it wouldn't be possible to know which field was selected.

parseplatformorg commented 1 year ago

🎉 This change has been released in version 5.2.0-alpha.23

parseplatformorg commented 11 months ago

🎉 This change has been released in version 5.3.0-beta.1

parseplatformorg commented 11 months ago

🎉 This change has been released in version 5.3.0-alpha.1

parseplatformorg commented 9 months ago

🎉 This change has been released in version 5.3.0