How to Query a soft deleted record within another model with populate
See original GitHub issueI have a soft delete model where I would like any existence of such model as subquery Model will fetch all records such that A soft delete model Service
can be query from Payment
model with all records both deleted and undeleted. maybe a config on populate can be used to disable the override deleted: true
effect.
const payments: IPayment[] = await Payment.find().populate('service').exec();
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Re-using soft deleted records - Stack Overflow
Based on first query result, perform an UPDATE if it exists (and reverse isdeleted flag) or perform a true INSERT if it does...
Read more >A guide to soft-delete models in Laravel - Beyond Code
Add soft delete to the User model with a new column in the up() method of a new migration: Schema::table('users', function (Blueprint $table)...
Read more >Middleware sample: soft delete (Reference) - Prisma
The following sample uses middleware to perform a soft delete. Soft delete means that a record is marked as deleted by changing a...
Read more >Working With Soft Deletes in Laravel 8 and 9 (By Example)
The first step is adding the Illuminate\Database\Eloquent\SoftDeletes trait to the models. Below is an example model where we have set it up to...
Read more >Soft Deletes in Django - DEV Community
We can query our database filtering by is_deleted in order to exclude records that have been soft-deleted. Note.objects.filter(is_deleted=False) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check the one on my repo… I think I merged that and made use of it… once merged to the main repo… you can switch back but right now, you can use the merged one or create a fork to your repo for usage.
Thanks
On Thu, 06 Feb 2020 at 7:12 PM, Rony Vidaur notifications@github.com wrote:
– Kazeem Olanipekun, Advanced Software Engineer P: +234(0)813 506 1846, W: kdevs.com.ng.
There is a PR that resolved this issue using configuration options in populate. I clone the repo and merge to master but on my personal Repo for now. You can check that and fork from original writer.
You can then do “populate({ path: “service”, options: { withDeleted: true}}). “
Thanks.
On Thu, 06 Feb 2020 at 6:53 PM, Rony Vidaur notifications@github.com wrote:
– Kazeem Olanipekun, Advanced Software Engineer P: +234(0)813 506 1846, W: kdevs.com.ng.