You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have actually a case where I have several endpoints, like
(1) /endpoint1
(2) /endpoint1/{id}/endpoint2
And the idea is be able to send in endpoint1 a full json (including the schema 1 and 2). At the same time, must be possible to use (2) to create a new endpoint2 or GET it.
At this time I have a (not nice) workaround, where I duplicate the models and replace the relationship decorators with properties (hasMany -> property.array) and use the second model in the controller to check the request-body.
In addition, my repository implements a logic to take apart the endpoint1 and call several other repositories and transform a single POST to several DB inserts.
Any better idea of how to implement this?
The text was updated successfully, but these errors were encountered:
The closest example I know of is in the Loopback4-shopping-example that involves two repository calls inside the controller.
// create the new userconstsavedUser=awaitthis.userRepository.create(_.omit(newUserRequest,'password'),);// set the passwordawaitthis.userRepository.userCredentials(savedUser.id).create({password});
Hi,
Now that LoopBack supports the inclusion of related models (https://strongloop.com/strongblog/inclusion-of-related-models/) I'm trying to figure out if there is a way to do the same for POST operations. (looks that no, based on #3439)
I have actually a case where I have several endpoints, like
(1) /endpoint1
(2) /endpoint1/{id}/endpoint2
And the idea is be able to send in endpoint1 a full json (including the schema 1 and 2). At the same time, must be possible to use (2) to create a new endpoint2 or GET it.
At this time I have a (not nice) workaround, where I duplicate the models and replace the relationship decorators with properties (hasMany -> property.array) and use the second model in the controller to check the
request-body
.In addition, my repository implements a logic to take apart the
endpoint1
and call several other repositories and transform a single POST to several DB inserts.Any better idea of how to implement this?
The text was updated successfully, but these errors were encountered: