Bulk delete #1030
Bulk delete #1030
Conversation
d4b10e3
to
6da4a44
Are you basically attempting to make DELETE a batch operation, whereas so far it's been an individual (document endpoint) or complete (resource endpoint) operation? |
getattr(app, "on_delete_resource")(resource) | ||
getattr(app, "on_delete_resource_%s" % resource)() | ||
default_request = ParsedRequest() | ||
if config.DOMAIN[resource]['soft_delete']: |
nicolaiarocci
Jun 21, 2017
Member
could use resource_def
here?
could use resource_def
here?
Amedeo91
Jun 21, 2017
Author
right
right
if config.DOMAIN[resource]['soft_delete']: | ||
# get_document should always fetch soft deleted documents from the db | ||
# callers must handle soft deleted documents | ||
default_request.show_deleted = True |
nicolaiarocci
Jun 21, 2017
Member
Why returning already deleted documents to the callback? Busines logic should have been applied on original deletion, right?
Why returning already deleted documents to the callback? Busines logic should have been applied on original deletion, right?
Amedeo91
Jun 21, 2017
Author
Well, in this case, I would like to offer to the client possibility to customize what he wants to delete. A possible use case can be that in the collection there are documents which should not be deleted by the client (i.e. included service for a trip, like included car or included checked baggage).
Therefore, it might be possible by modifying the query (in the case on hard delete) or modify the originals (removing what we do not what to delete) in the callback.
Well, in this case, I would like to offer to the client possibility to customize what he wants to delete. A possible use case can be that in the collection there are documents which should not be deleted by the client (i.e. included service for a trip, like included car or included checked baggage).
Therefore, it might be possible by modifying the query (in the case on hard delete) or modify the originals (removing what we do not what to delete) in the callback.
Hi Nicola, basically, I just want to enforce that we should delete what we fetch. Therefore, if in the URL we are allowing to specify some parameters (i.e. person with for follow url users/<regex("[a-f0-9]{24}"):person>/invoices --> lookup = {"person" : value}), we should use the some parameters to do the delete. |
@@ -38,7 +38,7 @@ def deleteitem(resource, **lookup): | |||
|
|||
|
|||
def deleteitem_internal( | |||
resource, concurrency_check=False, suppress_callbacks=False, **lookup): | |||
resource, concurrency_check=False, suppress_callbacks=False, original=None, **lookup): |
nicolaiarocci
Jun 22, 2017
Member
missing docstring update here
missing docstring update here
@@ -150,7 +149,8 @@ def deleteitem_internal( | |||
app.media.delete(original[field], resource) | |||
|
|||
id = original[resource_def['id_field']] | |||
app.data.remove(resource, {resource_def['id_field']: id}) | |||
# We should delete what we fetch. Since the id_field might not be unique, let's use the lookup |
nicolaiarocci
Jun 22, 2017
Member
this comment can be deleted
this comment can be deleted
if resource_def['soft_delete']: | ||
# get_document should always fetch soft deleted documents from the db | ||
# callers must handle soft deleted documents | ||
default_request.show_deleted = True |
nicolaiarocci
Jun 22, 2017
Member
this behavior should probably be explained in the Soft Delete section of the docs. Explain that the new callback will include soft-deleted documents when soft delete is active.
this behavior should probably be explained in the Soft Delete section of the docs. Explain that the new callback will include soft-deleted documents when soft delete is active.
@@ -21,6 +21,27 @@ def test_unknown_resource(self): | |||
_, status = self.delete(url) | |||
self.assert404(status) | |||
|
|||
def test_bulk_delete_id_field(self): |
nicolaiarocci
Jun 22, 2017
Member
the new DELETE behavior should be explained in the docs, probably in the Sub Resources of the features page.
the new DELETE behavior should be explained in the docs, probably in the Sub Resources of the features page.
f7b2cb4
to
1753b1d
Hi Nicola, thanks for your review! :) I did the update you suggested to me. Regards, |
Could you please squash all commits into one? |
Ciao Nicola, commit uniti! :) Ciao, |
Hi @nicolaiarocci, is there anything else I should do for this PR? Regards, |
Merged after a rebase and some fixes, see 63d87fc. Thanks! |
* 'master' of https://github.com/pyeve/eve: (374 commits) Changelog for pyeve#1070 use OrderedDict from backport_collections Minor changelog fixes for pyeve#1048 Support Decimal type MongoDB Changelog: add reference to proper PR Changelog update for pyeve#1042 Fix a serialization bug that randomly skips fields if "x_of" is encountered Amedeo Bussi Changelog for pyeve#1030 pep/flake, and remove duplicate test documentation improvements and fixes Bulk delete MONGO_DBNAME can be now used along with MONGO_URI Vasilis Lolis typo Amedeo91 Changelog for pyeve#1031 Bulk Embedded document resolution Delete unnecessary code Fix insidious bug in tests.TestPost class ...
Bulk delete fix +Adding callback on the bulk delete flow for customization purpose
Issue #1028
Issue #1010 --> to support the possibility to perform a bulk delete with a multi key unique id (Note: only for not soft delete, as per soft delete is possible to achieve it with customisation in the datalayer)