2016-04-25 20 views
-4

モデル内の配列を更新しようとしています。しかし、上記のエラーがスローされます。理由を知らない。 usagePlanは、更新が試行される前に定義されます。Node.js未知の例外typeError:未定義のpreoprty 'を設定できません

customer.usagePlan.toolUsage.tools.push(aNewToolObject); 
customer.updateAttribute('usagePlan',customer.usagePlan,function(err,something) { 
    //exception is thrown here 
}); 

エラー:更新属性の

uncaught Exceptions: TypeError: Cannot set property 'usagePlan' of undefined 

ドキュメントは、ここで見つけることができます:

http://apidocs.strongloop.com/loopback/#persistedmodel-prototype-updateattribute

+1

あなたはupdateAttribute関数のコードを共有することができます

あなたは、第二引数は、プロパティ自体ではなく、オブジェクトなどがよろしいですか? –

+1

これ以上のコードを提供する必要があります。このコードはそのまま実行することはできません。 – Tibrogargan

+0

そのエラーは、 'customer.usagePlan'が定義されていないように見せます。 'updateAttribute'という名前に基づいて、' customer.usagePlan'の代わりに 'customer'オブジェクトを渡すべきかもしれないようです。 – jfriend00

答えて

0

updateAttributeのコードを何ですか?

customer.updateAttribute('usagePlan',customer,function(err,something)  
+0

はい、customer.usagePlanを変数に代入して関数に追加すると、エラーはそのまま残ります。 – hownowbrowncow

+0

例外として、未定義のオブジェクトに対してusagePlanプロパティを取得しようとしています。 updateAttribute関数のコードを共有してください。 –

+0

それは意味をなさない。 usagePlanはよく定義されていて、この関数が呼び出される前に使用されていた内容を持っています。すべてのupdateAttributeは、この属性の変更をDBに保存します。 – hownowbrowncow

関連する問題