Javascript 如何检查服务钩子中的关联
我正在使用 我读过这本书 我如何执行这个方法来检查服务钩子,或者告诉我另一种检查方法Javascript 如何检查服务钩子中的关联,javascript,associations,sequelize.js,feathersjs,feathers-sequelize,Javascript,Associations,Sequelize.js,Feathersjs,Feathers Sequelize,我正在使用 我读过这本书 我如何执行这个方法来检查服务钩子,或者告诉我另一种检查方法 const { disallow } = require('feathers-hooks-common'); function include() { return function (hook) { const productPrice = hook.app.service('product-prices').Model; const currencies = hook.app.serv
const { disallow } = require('feathers-hooks-common');
function include() {
return function (hook) {
const productPrice = hook.app.service('product-prices').Model;
const currencies = hook.app.service('currencies').Model;
const edizm = hook.app.service('edizm').Model;
const pricesShema = { model: productPrice,
include: [
{
model: currencies,
attributes: ['title', 'socr']
},
]
};
const edizmShema = { model: edizm,
attributes: ['title', 'detail']
};
let association={include: [edizmShema, pricesShema]};
hook.params.sequelize = Object.assign(association,{ raw: false });
return Promise.resolve(hook);
}
}
module.exports = {
......
};
如前所述:
Feathers钩子使用POJO而不是DB ORM,并且您的raw:false
返回ORM
如果您确实无法使用raw:true
,请将ORM转换为POJO:
const dehydrate = require('feathers-sequelize/hooks/dehydrate');
hooks.after.find = [dehydrate(), discard('password')]
你可以(如果你真的需要的话)