-
Notifications
You must be signed in to change notification settings - Fork 96
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
option.id ignored in _get #58
Comments
It seems like that shouldn't even be an option. Mongo DB doesn't allow you to use a different ID property. http://stackoverflow.com/questions/15854693/mongodb-how-to-set-another-field-different-from-id-as-id-of-mongo-document |
I already kicked this out of NeDB (see feathersjs-ecosystem/feathers-nedb#11). We should remove it here as well and take it out of the docs. |
@marshallswain you are right mongo does require each doc to have an |
So... looking at the code. I don't think we should actually remove this option. If someone wants to index a certain attribute and use that as their primary id they should be able to. It's not a very common case but I could see that happening. Say if you wanted to look people up by a slug, uuid, or incremental id. In fact, in order to stay database agnostic for your data model, it's actually a good practice to assign uuid's to all of your records rather than use the default database id. So I'm just going to fix it so that the queries use the |
get should use the options.id attribute. Closes #58
Thanks for quick response and bugfix! Now I have one more problem. It's not a bug, but I don't know how to handle this. I'm working with the "ep_votes.json.xy" file from The file contains votes of EU Parliament Members. The query doesn't look that difficult: BUT it doesn't work, because the "ep_id" is a number in the json file. |
@robotnic you can create a before hook to access hook.params.query.ep_id and change it to the type you want. |
Looks like @marshallswain beat me to it. This is how it could look: const hook = require('feathers-hooks');
app.configure(hooks());
app.service('members').before({
find(hook) {
const epId = hook.params.groups.votes.ep_id;
if(epId) {
hook.params.groups.votes.ep_id = parseInt(epId, 10);
}
}
}); |
lol I was about to respond now too but @marshallswain and @daffl beat me to it. Nice work team! 😄 There is a chance that you might need to convert your query to a nested object instead of using the dot notation. Report back if the dot notation works. I haven't tried it yet. |
That syntax works
|
👍. Thanks @robotnic! |
Here is a query to _id even if this.id is set to an other parameter.
https://github.com/feathersjs/feathers-mongoose/blob/58020126684aa06ab12c653d9acfdd372c147254/src/service.js#L97
Desired functionality:
Use the id specified in option.id
The text was updated successfully, but these errors were encountered: