Closed DanStorm closed 5 years ago
I think you can do a PR to support that. Some clues to do it:
add in options a softDelete flag with false as defulat
const options = {
id: 'id', // If your database uses an id field other than 'id'. Optional.
usePatch: false, // Use PATCH instead of PUT for UPDATE requests. Optional.
softDelete: false,
my_resource: { // Options for individual resources can be set by adding an object with the same name. Optional.
id: 'id', // If this specific table uses an id field other than 'id'. Optional.
},
}
Then for PATCH, UPDATE or UPDATE_MANY you can check if softDelete is true, if is you add $ignoreDeletedAt: true
to data (sent to feathers client)
Tell what do you think about?
@josx Thanks for the reply! I have been looking into this, and think this is what you're suggesting. In /node_modules/ra-data-feathers/lib/restClient.js
starting line 83
case _reactAdmin.UPDATE:
if (usePatch) {
var data = params.previousData ? (0, _objectDiff2.default)(params.previousData, params.data) : params.data;
data.ignoreDeletedAt = true; // ADDED BY ME
return service.patch(params.id, data);
} else {
var _data = idKey !== defaultIdKey ? deleteProp(params.data, defaultIdKey) : params.data;
return service.update(params.id, _data);
}
(I am not checking for softDelete
before adding ignoreDeletedAt
at the moment, I will add the conditional for that later.) I am attempting to send a request to my local api server with ignoreDeletedAt
in the right spot. SoftDelete.js
is looking for context.params.$ignoreDeletedAt
, but adding data.ignoreDeletedAt = true;
as above, places ignoreDeletedAt in context.data
and context.arguments[1]
. Any ideas on how would I go about getting that option into context.params
Thanks again!
Check feathers doc: https://docs.feathersjs.com/api/services.html#patchid-data-params
You have to send a third argument to that function in this way:
service.patch(params.id, data, { ignoreDeleteAt: true});
Awesome, thanks for that! I was able to get it to show up on my server by using paramsForServer
from feathers-hooks-common
(and on my server I use paramsFromClient
to allow it in) . I am hoping it will be okay to add that dependency. I will create a PR with my changes soon.
I have not been working with Node and related technologies that long, and therefore I am not really familiar with how your repo is set up. In my local server, ra-data-feathers
has a lib
folder (complied by babel, maybe? idk), which is where I made my changes for testing locally. For the pull request, I just ported my changes into src/restClient.js
If that is problematic or just completely wrong, please instruct and I will correct, thanks!
I have posted the following question on stack-overflow as well. https://stackoverflow.com/questions/57599531/softdelete-and-react-admin-how-do-i-send-extra-params-to-the-api-during-update
We are using softDelete, from feathers-hooks-common for our users. In order for us to edit (or undelete) users that have been softDeleted, we need to pass
$ignoreDeletedAt: true
to the api in the update request. I have been digging through the react-admin and ra-data-feathers documentation, but I don't see a way to do that.We are using the ra-data-feathers data provider, which says this:
This
my_resource
option is the only place I have seen in the documentation to interact with the query. I have tried to add a 'users' resource to Admin to pass my parameterI have also attempted a few other syntaxes, but nothing extra seems to be passed to the server when trying to update the user. Any direction would be most welcome. Thanks in advance.