2015-02-06 64 views
0

我使用風帆0.10.5,我有兩個模型,如下面的許多關係。但我在解除應用程序時出錯。風帆mongo多對多協會不工作

模型1)Category.js

attributes: { 
     name: { 
      type: 'string', 
      required: true 
     }, 
     features: { 
      type: 'array' 
     }, 
     desc: { 
      type: 'string' 
     }, 
     sub_cats: { 
      collection: 'SubCategory', 
      via: 'cats', 
      dominant: true 
     } 
    } 

模型2)SubCategory.js

attributes: { 

     cats: { 
      collection: 'Category', 
      via: 'sub_cats' 
     }, 
     name: { 
      type: 'string', 
      required: true 
     }, 
     features: { 
      type: 'array' 
     }, 
     desc: { 
      type: 'string' 
     } 
    } 

現在同時擡起帆的應用程序,該錯誤始終觸發

"C:\Program Files (x86)\JetBrains\PhpStorm 8.0.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" app.js 

c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47 
    return hop.call(obj, prop); 
      ^
TypeError: Cannot convert null to object 
    at hasOwnProperty (native) 
    at exports.object.hasOwnProperty (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\utils.js:47:14) 
    at JoinTables.parseAttribute (c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:148:26) 
    at c:\wamp\www\holymantra\hm\node_modules\sails\node_modules\waterline\node_modules\waterline-schema\lib\waterline-schema\joinTables.js:83:22 
    at Array.forEach (native) 

所以我很困惑(我的代碼錯誤或存在帆 - 蒙戈多對多的關係有些問題)

--ND

回答

1

它只是在SubCategory.js一個錯字:它應該是attributes代替attribute

+0

雅你是對的,但我仍然有同樣的錯誤:( – 2015-02-11 04:53:42

+0

你可以嘗試啓動應用程序與'帆升降機或節點app.js'從控制檯? – irobert91 2015-02-11 20:29:15

+0

@NishchitDhanani和你有任何其他模型? – irobert91 2015-02-12 07:14:27

1

希望你現在已經解決了你的問題!對於像我這樣的人遇到這個錯誤,balderdashy/waterline-schema剛剛發佈了一個更有用的錯誤消息,https://github.com/balderdashy/waterline-schema/issues/17這應該可以幫助您找出您的特定問題。

  1. 導航到node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema(注:由於截至今日(2015年4月28日),故宮安裝不給你這個最新的版本,您可以手動執行以下解決它,這可能是在全局帆目錄)
  2. 更換joinTables.jshttps://github.com/balderdashy/waterline-schema/blob/8f5a44d076ca36edea409bf41ac2cdbf760c2c59/lib/waterline-schema/joinTables.js

我知道這並不完全回答你的問題,以什麼地方出了錯,但希望它會給別人與錯誤的工具,更迅速地解決問題。