I'm implementing the (not so well documented) loopback method nestRemoting()
as follows:
module.exports = function(MyModel) {
MyModel.on('attached', function() {
MyModel.nestRemoting('relationName');
});
}
However this seems to be very temperamental. Sometimes it works, but most of the time I get:
Relation `relationName` does not exist for model `MyModel`
at ....stacktrace....
.....
Does anyone know why this error might be occurring?
So, I found the solution only moments after posting - you can only do nestRemoting
after the model has been attatched
... not attached
. Simple spelling mistake can fix all woes.
Perhaps this post will help someone else trying to nest endpoints.