Closed sunilsmith closed 3 years ago
Transferred to loopback-next
repo because this is about LB4.
@sunilsmith, cross-posting my response to your stackoverflow post:
You need to create a AuthorBookController to connect the two. Please see example code in here: https://github.com/strongloop/loopback-next/blob/master/examples/todo-list/src/controllers/todo-list-todo.controller.ts
Hi,
Why not in author controller just call in deleteById
function :
this.authorRepository.books(id).delete();
?
The function deleteById of a repository is able to take Options, the reference api doesn't describe them. What are them ? Not possible to give a cascade option ?
(method) DefaultCrudRepository<Category, number | undefined, CategoryRelations>.deleteById(id: number | undefined, options?: AnyObject | undefined): Promise<void>
Thanks a lot!
While saving data using ORM models the cascading is not happening
LoopBack does not support cascading operations (create, update, delete).
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository. This issue will be closed within 30 days of being stale.
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS
file at the top-level of this repository.
I have created 2 models Author and Books where Author has hasMany relation with Book and Book has belongsTo relation with author. While saving data using ORM models the cascading is not happening i.e
The above should create a Author record in Author table and create a Book record with the authorId in Book table, which is not happening whereas from belongsTo it can able to create an Author record with just authorId. can find the code in the following GIT