AWS S3 buckets - Forcing to used custom route of related data?

Feature(s) impacted

Overriding route -
For my back office, I needed to customized the delete route of some of my tables to simultaneously delete my s3 associated bucket.

For instance, my users have their profile picture stored in s3: so I custom the delete route to force the s3 to be emptied at the same time.

I overrided both the delete and delete list route. In the delete list route, I had to rewrote everything iterating on each list member.
My first question is: is there a way to simply tell to the delete list override route to use the overrided simple element route? i.e. iterating on each list member and simply calling the delete route instead of having to rewrite everything.

My second question is similar:
My users have others related data, which also have s3 coresponding files. So for these related data, I’ve also overrided both the delete and delete list route.

Now, I want that when deleting a user, the related data are also deleted. This is correctly handled, but doesn’t use my override delete route for each related data. This means taht the related data are corrected destroyed, as well as the user s3, but, the related data s3 are not deleted.

Again, is there a way to force Forest to directly use the overrided route of the related data? Otherwise that I would have to, again, do manually the samed things on the delete user route, adding manually the delete of each s3 related data.

I hope my explanation was clear! I would be happy to provide more detail if needed.

Thanks a lot for your help,
Chloé.

Observed behavior

Forest overrided route are not used for related data.

Expected behavior

I would like to know if there is an option to directly force forest to use the override route of each related data.

Context

Forest & SQL

Hello @ChloeG,

Thanks for your message, that’s an interesting use case.

A simple way to do this is to create a service that handle all your logic with S3 buckets. This way you can have less code to write in the delete routes.

Same thing here you need to extract the code (logic) that handle the s3 deletion and then call it in where ever you need it.

We know that’s not ideal when you use external service and you need to handle custom logic in multiple places. Depending on the type of relationships you can also use Sequelize Hooks (afterDestroy for example) to do your custom logic on external resources.

Kind regards,
Morgan

Hi Morgan,

Thanks for your reply. I had a look at the Sequelize Hook, and they can definitly be a nice solution considering my use-case, thanks a lot for your help. For handling my s3 buckets, yes I’ve already created a service, but I was looking for a way to minimize code repetition :slight_smile:

I also use this thread to kindly ask you if you would have some use-cases, examples, or forum discussions about handling AWS cognito users and Forest Admin? I couldn’t find a lot about this. Indeed, my users pool are managed by a cognito pool, so I also have to create custom delete route to also handle simultaneously the user deletion in Cognito. I’m now looking for a simple way to create a user from Forest Admin and Cognito at the same time and I’m bit confused, so I was wondering if you have some content about Forest / cognito interaction.

And the last thing (it’s more a suggestion): when having the main view of a table, like this:

Is there a way to display in this view some related data directly? I know we can easily do it in the summary view, when clicking on a table item, but I was looking for displaying directy a related data in the list, cause I want to have a quick overview of my data. Is there a way to do this or is this is a feature you’ve already planed to develop?

Thanks a lot for your help!!

Have a nice day,
C.

Hi again,

I get it. Indeed today we have to provide custom code to handle such external data source. We are already working on solution to get better at handling those use-case (external data management). I can’t provide you any date at the moment but stay tune.

I haven’t use this AWS cognito users service. At Forest Admin we provide identity through OpenID Connect process which seems compatible with this service. I will ask some colleagues on this topic.

We also provide Single sign-on support for any SAML v2 compatible IDP. So you can use SSO provider to manage user authentication.

Not really. You can use SmartField to add a field (column) into this view but that’s pretty basic.

Example of SmartField that display related data field:

fields: [{
    field: 'relatedData',
    type: 'String',
    get: (record) => {
      return models.someCollection
        .findAll({ where: { id: record.someCollectionId } })
        .then((someCollectionRecords) => {
          return someCollectionRecords.reduce((acc, value)=> {
            return acc + value.fieldYouWantToDisplay;
          }, '');
        });
    }
  }]

We are working on some related topic but I can’t give any estimate date. :slightly_frowning_face:

Finally, I invite you to read some example on our woodshop, you can find some interesting examples on multiple topics.

Kind regards,
Morgan