Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support soft-delete for tables from 'plugins' #5

Open
SvaRgoS opened this issue Dec 5, 2023 · 7 comments
Open

Add support soft-delete for tables from 'plugins' #5

SvaRgoS opened this issue Dec 5, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@SvaRgoS
Copy link

SvaRgoS commented Dec 5, 2023

Is your feature request related to a problem? Please describe.

For all entities from api section softDelete works correctly.

But for @strapi/plugin-users-permissions
SofDelete didn't add the fields

_softDeletedAt: Attribute.DateTime & Attribute.Private;
_softDeletedById: Attribute.Integer & Attribute.Private;
_softDeletedByType: Attribute.String & Attribute.Private;

But for queries (update up_users) apply.

Describe the solution you'd like
in the strapi-plugin-soft-delete/utils/plugin.ts


export const supportsContentType = (uid?: string) => {
  return uid?.match(/^api::/) || false;// || !uid?.match(/^\w+::/) || false; // TODO: Deleting a compoment doesn't use the entityService
};

replace by


export const supportsContentType = (uid?: string) => {
  return uid?.match(/^api::/) || uid?.match(/^plugin::/) || false;// || !uid?.match(/^\w+::/) || false; // TODO: Deleting a compoment doesn't use the entityService
};

@SvaRgoS SvaRgoS added the enhancement New feature or request label Dec 5, 2023
Copy link
Owner

How would you restore plugin's soft deleted items?

@SvaRgoS
Copy link
Author

SvaRgoS commented Dec 5, 2023

I thought to call action restore no?

If it is too difficult, we can avoid to add softDeletedAt to queries for non 'api:...' entity.

@t-fritsch
Copy link

Hi, I just saw this issue and I think that what you say here @SvaRgoS ("we can avoid to add softDeletedAt to queries for non 'api:...' entity.") is related to an issue I just posted : #6
Am I wrong ?

@SvaRgoS
Copy link
Author

SvaRgoS commented Dec 6, 2023

Yeah, I think that is correct.
So, this issue can be closed as a duplicate.

@t-fritsch
Copy link

If I'm not wrong this current issue is a feature request about adding support for core tables.
#6 is a bug report in current implementation.

The two issues even if related (core tables) are then different, because with different objectives. Fixing the bug could be first done in emergency since it breaks current installations (bugfix 0.9.4) and this present issue could be done later as a new minor/major version (0.10.0 or 1.0.0) depending of the feature being backward compatible with current implementation (ie. not supporting core tables by default, and enabling it with a config param).
what do you think ?

@SvaRgoS
Copy link
Author

SvaRgoS commented Dec 6, 2023

You look more widely at this issue. This is a more correct point of view I am sure. It was my first thought - I tried to find something in the config to add softDelete to the plugin's table, and then, when we found the issue with a query to the plugin:up_users table, I checked the config again :-)

So it is a good place to manage enabled tables I think. May be enabled prefixes.
I am not familiar with Strapi yet. That is why I don't know is it heavy to add a restore endpoint to "plugin's" tables or no.
Let me know if I can help you with something!

@kevinvugts
Copy link

kevinvugts commented Dec 8, 2023

You look more widely at this issue. This is a more correct point of view I am sure. It was my first thought - I tried to find something in the config to add softDelete to the plugin's table, and then, when we found the issue with a query to the plugin:up_users table, I checked the config again :-)

So it is a good place to manage enabled tables I think. May be enabled prefixes. I am not familiar with Strapi yet. That is why I don't know is it heavy to add a restore endpoint to "plugin's" tables or no. Let me know if I can help you with something!

The soft delete function is not applied to collection types that are created via a custom plugin. The problem stams from https://github.com/ChristopheCVB/strapi-plugin-soft-delete/blob/de490e7838c7270c2f44d02e3684670ad62b548c/utils/plugin.ts#L6C1-L8C3

is it possible to enable the soft delete for collection types of plugins as well? Or is this something that I can achieve by overriding it via extensions?

In addition to the above, when you populate "deep" or populate data in general, the records are still populated even though they are soft deleted. This shouldn't happen in my opinion. Can you elaborate more on this and a possible solution to this?

Please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants