We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HI guys. I have a problem. help me please.
I have API url example this: PUT /api/mcus/{id}/trailer/{trailerId} Assign MCU device to Trailer
Trailer Model
var Trailer = restmod.model('api/trailers'); Trailer.mix({ mcu: { hasOne: 'Mcu'} });
Mcu Model
var Mcu = restmod.model('api/mcus'); Mcu.mix({ trailer: { belongsTo: 'Trailer'}, });
Update Mcu model
vm.model = Mcu.$find(1).$then(function(){ var trailer = TrailerModel.$find(3).$then(function(){ vm.model.trailer = trailer; vm.model.$save(); // url PUT /api/mcus/1 vm.model.trailer.$save() // url PUT /api/trailers/3 })
In mcu model i have this json
{ "id":1, "deviceId":5336091833, "serialNo":"test", "ipAddress":"127.0.0.1", "trailer":{ "id":3, "title":"Test Trailer", "description":"test" }, "sensors":[ ] }
Whot I have to do to get this link? // PUT /api/mcus/{id}/trailer/{trailerId}
Thanks!
The text was updated successfully, but these errors were encountered:
You don't want to be mixing belongsTo and hasOne. Those are two different styles of relations. You would want to define it like the following:
belongsTo
hasOne
var Trailer = restmod.model(); // Note that we're not passing a route var Mcu = restmod.model('api/mcus'); Mcu.mix({ trailer: { hasOne: Trailer}, });
Sorry, something went wrong.
No branches or pull requests
HI guys. I have a problem. help me please.
I have API url example this:
PUT /api/mcus/{id}/trailer/{trailerId} Assign MCU device to Trailer
Trailer Model
Mcu Model
Update Mcu model
In mcu model i have this json
Whot I have to do to get this link? // PUT /api/mcus/{id}/trailer/{trailerId}
Thanks!
The text was updated successfully, but these errors were encountered: