-
Notifications
You must be signed in to change notification settings - Fork 74
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
Private method _get() not processing parameters #22
Comments
What would params do? It doesn't look like Model.findById takes options like that. |
@daffl I think we used to use |
Well what @kulakowka is saying that it is removed in |
@daffl I don't think we should do that. it's over complicating things. Unless we have a case where you really need to pass params to a get, it should just take an |
I use it for populate app.service('/api/v1/tutorials').after({
get (hook) {
const creator = hook.result.creator
const userService = hook.app.service('api/v1/users')
return userService.get(creator, {
query: {
$select: {'username': 1}
}
}).then((user) => {
let result = hook.result.toJSON()
result.creator = user
hook.result = result
return hook
})
}
}) I think that we should be able to specify parameters for the .get () method. for example in order to be able to specify which fields should be returned from the database. |
I agree. We just need to make sure that this works the same for all database adapters. Basically the only relevant field would be |
@daffl yes. Other I have a situation where I need to get the record for two keys. Look this for example: Project.findOne({platform: 'npm', name: 'feathers'}) Maybe you can redesign the interface for method For example so: app.service('projects').get({ platform: 'npm', name: 'feathers' })
app.service('todos').get({ id: 123 })
app.service('todos').get(123) |
Hmmm... maybe we can make it so: |
@kulakowka in your case you could easily do a I think |
I'm not able to use |
It's easy to fix: https://github.com/feathersjs/feathers-sequelize/blob/master/src/index.js#L58-L59 _get(id, params) {
return this.Model.findById(id, params.sequelize).then(instance => { ... |
I published a fix for @mrpatiwi's issue. The other issue discussed can now be solved by adding a app.service('myservice').before({
get(hook) {
if(typeof hook.id === 'object') {
return this.find(hook.id).then(result => {
const data = result.data || result;
hook.result = data[0];
return hook;
});
}
}
}); |
In method
.get()
it is possible to pass parameters to the query.For example, so:
But it does not work!
I found the cause. Private method
_get()
only takes one parameterid
:But it must take two parameters
id
andparams
.The text was updated successfully, but these errors were encountered: