Javascript FeathersJS中的非积垢路由
我有一个服务Javascript FeathersJS中的非积垢路由,javascript,feathersjs,feathers-sequelize,feathers-hook,feathers-service,Javascript,Feathersjs,Feathers Sequelize,Feathers Hook,Feathers Service,我有一个服务results,它在feathersjs中处理results服务的所有CRUD操作。我如何创建一个route/results/:id/hr\u bar\u graph,它基本上获取该特定id的结果,并使用结果数据创建一个条形图 我目前的代码是: module.exports = function (app) { const Model = createModel(app); const paginate = app.get('paginate'); const opti
results
,它在feathersjs
中处理results
服务的所有CRUD操作。我如何创建一个route/results/:id/hr\u bar\u graph
,它基本上获取该特定id的结果,并使用结果数据创建一个条形图
我目前的代码是:
module.exports = function (app) {
const Model = createModel(app);
const paginate = app.get('paginate');
const options = {
name: 'results',
Model,
paginate
};
// Initialize our service with any options it requires
app.use('/results', createService(options));
app.use('/results/:id/hr_bargraph_image', {
find(id, params){
this.app.service('results').get(id)
.then(function(response){
console.log(response);
})
.cathc(function(error){
console.log(error);
})
return Promise.resolve({
imageData: ''
});
}
});
// Get our initialized service so that we can register hooks and filters
const service = app.service('results');
service.hooks(hooks);
};
我被困在这里有一段时间了。请提供帮助。作为参考,从中,答案是使用和使用:
如何将结果服务上的相同挂钩应用于此定制服务?不影响
结果的工作
服务
module.exports = function (app) {
const Model = createModel(app);
const paginate = app.get('paginate');
const options = {
name: 'results',
Model,
paginate
};
// Initialize our service with any options it requires
app.use('/results', createService(options));
app.use('/results/:id/hr_bargraph_image', {
async find(params){
const { id } = params.route;
const results = await app.service('results').get(id);
return {
imageData: ''
};
}
});
// Get our initialized service so that we can register hooks and filters
const service = app.service('results');
service.hooks(hooks);
};