-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Hello
I have a question where I cannot find the solution for in the documentation.
My Understanding is that when you use the .save() function, the foreign key of all all missing child objects will be set to null. Is there a 'nice' way to remove those objects from the database instead of setting the foreign key to null, using the save methode?
So for example if I have the following books in my database:
| id | name |
|---|---|
| 1 | Book x |
| 2 | Book y |
And save the following object:
Author: {
name: "...",
books: [
{
name: "Book z",
},
{
id: 2
name: "Book yy",
}
]
}
const authorRepository = getConnection('database').getRepository(Author);
await authorRepository.save(author);
The result should be:
| id | name |
|---|---|
| 2 | Book yy |
| 3 | Book z |
I'm using version: 0.2.0-alpha.12.
Thanks
Reactions are currently unavailable