4

我在使用feathersjs。我已閱讀documentation如何查看關聯羽化 - 在服務鉤中使用sequelize

如何執行此方法來檢查服務鉤羽毛鉤或告訴我另一種檢查方法。

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 = { 
    ...... 
}; 

回答

0

至於解釋here: 羽毛鉤與POJO的工作不是與DB ORM的,和你的raw: false返回一個ORM。

如果你真的不能使用raw: true那麼ORM轉換成POJO:

const dehydrate = require('feathers-sequelize/hooks/dehydrate'); 
hooks.after.find = [dehydrate(), discard('password')] 

可以convert back to an ORM(如果你真的需要)。

相關問題