2016-11-09 55 views
1

我使用Loopback v3,當我嘗試引用另一個模型 時,例如。 customer.js,與Loopback 3應用程序對象未定義?

module.exports = function(Customer) { 

    var Product = Customer.app.models.Product; 

它崩潰說

TypeError: Cannot read property 'models' of undefined 

有什麼想法?

回答

-1

您是否在兩個模型之間添加了關係? 確保您已經在Customer.json和Product.json上定義了Customer和Product模型之間的關係。 這可以手動完成或使用環回生成器。

slc loobpack:relation 

點擊此處瞭解詳情:http://loopback.io/doc/en/lb2/Creating-model-relations.html

相關問題