Inconsistent between GET and DELETE on related models
DELETE /Customers/{id}/thankBooks
- This doesn't have filter
GET /Customers/{id}/thankBooks
- This have filter
I think we need to apply filter for DELETE method instead of delete all records of related model.
After find and research i found that:
setRemoting(PersistedModel, 'destroyAll', {
description: 'Delete all matching records',
accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
http: {verb: 'del', path: '/'},
shared: false
});
Why do you need to set this remoteMethod is hidden ?
@bajtos I have the same question and what do you think about this ?
I don't know much about this part of loopback and loopback-datasource-juggler, @fabien or @raymondfeng are more suited to answer your questions.
@bajtos thanks and wait for answer from @fabien or @raymondfeng ;)
@bluestaralone Is that issue still relevant?
You can use
DELETE /Customers/{id}/thankBooks/{fk}
to delete a specific record of a thankBooks of the customer mode. let me know if that's not what you are looking for.
@loay Arcording to your way, we just delete only one record, but my need is deleting multiple records.
@bluestaralone I thought that's what you were looking for.
So basically the current workaround would be:
delete the whole records for customers would be:
DELETE /Customers/{id}/thankBooks
delete specific thankBooks with a specific ID:
DELETE /Customers/{id}/thankBooks/{fk}
delete multiple records of thankBooks with a specific condition:
PersistedModel.destroyAll([where], callback)
Another example from the documentation: https://docs.strongloop.com/display/public/LB/Where+filter#Wherefilter-Whereclauseforupdatesanddeletes
To delete all records where the cost property is greater than 100:
productModel.destroyAll( { cost: {gt: 100} }, function(err, obj) { ... } )
I guess you were looking to add the filter in the API explorer page, correct?
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.