我是 FeathersJS 的新手,想在授权后向用户对象添加其他数据。(我想用 访问数据app.get('user').newData
)
首先,我尝试在 中设置一个值hook.result.newData
,但它不起作用。我只能更改现有值,例如电子邮件。
module.exports = function(options) {
return function(hook) {
hook.result.households = hook.app.service('households').find({'people.userId': hook.id}).then(household => {
console.log('households: ', household.data);
return household.data;
});
hook.result.email = '!' + hook.result.email + '?'; // this works
hook.result.newData = 'test'; // this doesn't work
};
};
我尝试的另一种方法是修改此处找到的代码片段:https ://github.com/feathersjs/feathers-hooks/issues/56但也没有成功。
但我也不确定如何填充我的情况。我想添加另一个服务的对象,这些对象具有一组用户 ID。我只想要那些在数组中包含自己的用户 ID 的对象。