-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upsert option with ID remapping is broken #91
Comments
You are sending the request to the service without an id. The URL should be the id you want to upsert, e.g. |
In the case of an insert, you have no ID so the endpoint call should be the same as a regular POST, right? Also, without ID remapping it is working as (I) expected. |
Upsert is supposed to update or create an existing id. If you don't have an existing id, you should use |
That's fine, but AFAIK it's it's not documented and the fact that it works without ID remapping is misleading. Still feels strange to me that upserting with the ID within the request (and not the route) is not supported, which does not seems natural. Either way, as with every design decision it's fine if you don't agree and do not plan to support it, but then it should at least throw the same error when trying to upsert without and ID in the route when ID remapping is not enabled, for consistency (as it currently works fine) 😃 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here. |
Steps to reproduce
See https://glitch.com/edit/#!/feathers-id-issue?path=README.md:3:60 for source code and repro:
feathers g app
with REST & NeDB optionfeathers g service
->scores
with NeDB optionscores.hooks.js
to enableupsert
for all PUT/PATCH requestsplayerId
(or whatever prop) inscores.services.js
curl -H 'Content-Type: application/json' --request PUT -d '{"playerId":1,"score":123}' https://feathers-id-issue.glitch.me/scores
--> ERRORExpected behavior
Enabling the NeDB
upsert
option works withid
option set on the model.Actual behavior
When enabling the NeDB
upsert
option withid
option set on the model, trying to perform an upsert results in an error:{"name":"BadRequest","message":"You can not replace multiple instances. Did you mean 'patch'?","code":400,"className":"bad-request","errors":{}}
Without the id remapping, it works fine.
System configuration
Tell us about the applicable parts of your setup.
Module versions (especially the part that's not working):
NodeJS version: v8.11.1
Operating System: OSX 10.13
Browser Version: N/A
React Native Version: N/A
Module Loader: N/A
The text was updated successfully, but these errors were encountered: