Closed yoieh closed 4 years ago
@yoieh Thanks for bringing this up. Soft delete is a tricky feature to manage and I'm definitely open to ideas. For your needs I think the current solution would be to select documents with isDeleted
equal to false
within the query itself, like so:
http://localhost:8080/permission?$page=2&$limit=10&isDeleted=false
This will give you proper pagination values excluding deleted documents. Does this make sense?
In my case I still need the deleted documents to be able to remove them from the client. But yes i went with a costume rout as a "sync route". That takes a lastSync=DATE
. Then I'm doing the "get list" call with isDeleted=false
. Not really optimal to do to calls every time an client updates but it works and also enables an case to update cached documentss on my client. Still there are some other problems with the amount of data that could be receiving buy a new user..
this what's why I needed a way to just know the amount of deleted items of the total.
@yoieh lets move the conversation to your PR: https://github.com/JKHeadley/rest-hapi/pull/236
Is your feature request related to a problem? Please describe. Do not know it this is a bug or not so I'm adding it here.
When soft delete is active shouldn't total items exclude deleted items? If not its impossible to tell how many items actually "exists" on a clients pagination.
Describe the solution you'd like exclude
isDeleted
documents from the total amount also recalculate the total amount of pages based of the new total amount.Describe alternatives you've considered An other solution would be to return total
isDeleted
amount as its own value in items asitems.deleted
but only if the total soft delete is activated. Then on the client side you could recalculate the number of pages as suchpages.total = Math.ceil(item.total - item.deleted / item.limit)