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

Possibility to control soft deleted records in query parameter like "withDeleted" ? #940

Open
webdevog opened this issue Jun 25, 2024 · 5 comments

Comments

@webdevog
Copy link

Hello!
Firstly, thank you for the great library and your work!
I need to control response by a filtering parameter like "withDeleted", so I can show to a user active records and deleted records depending on a some filter parameter (something like "withDeleted" or so on). So that user can restore deleted items etc.
Can you please tell me the correct way to control withDeleted results?
Thank you!

@Helveg
Copy link
Collaborator

Helveg commented Jun 26, 2024

I think this should be possible with the where: { deletedAt: null }/where: { deletedAt: Not(null) } in the configuration?

@webdevog
Copy link
Author

@Helveg thanks for your response, but again your proposal - it is kind of global filtering in configuration. We can achieve this using withDeleted: true or withDeleted: false in configuration.

I'd like to have withDeleted: false by default. So that - only active records are being returned in many places in my application, but in specific cases - for admin user purposes I'd like to specify some query parameter to return not only active records but deleted records (soft deleted to be precise) as well.

@ppetzold
Copy link
Owner

just pass your "custom query param" to the withDeleted config then ? 😅

@webdevog
Copy link
Author

@ppetzold thank you. For sure it will work, but I thought that it would be a nice feature to have it in a predefined set of parameters because I think it can be commonly used.
Anyway thank you, at least now I know that it is not build-in feature and I need to create my custom query parameter

@webdevog
Copy link
Author

webdevog commented Jun 26, 2024

Ok. I made such a solution without using any custom parameters:
findAll(query: PaginateQuery): Promise<Paginated<Facility>> { FACILITY_PAGINATE_CONFIG.withDeleted = query?.filter?.deletedAt === '$not:$null'; return paginate(query, this.r, FACILITY_PAGINATE_CONFIG); }

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

No branches or pull requests

3 participants