Hallo Ich versuche, dieses Beispiel https://docs.strongloop.com/display/public/LB/HasAndBelongsToMany+relations Ich habe diese beiden Modelle:Beziehungen Loopback
Teil
{
"name": "Part",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"partNumber": {
"type": "number"
}
},
"validations": [],
"relations": {
"parts": {
"type": "hasAndBelongsToMany",
"model": "Assembly",
"foreignKey": ""
}
},
"acls": [],
"methods": {}
}
Assembly
{
"name": "Assembly",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string"
}
},
"validations": [],
"relations": {
"parts": {
"type": "hasAndBelongsToMany",
"model": "Part",
"foreignKey": ""
}
},
"acls": [],
"methods": {}
}
Wenn ich versuche hinzufügen Ein Element in Assembly Ich habe ein undefiniertes Element.
Ich verwende
assembly.js
Assembly.parts.add(part, function(err) {
...
});
aber assembly.parts ist nicht definiert.
Was mache ich falsch? Danke