As someone who is new to nestjs, I am working with two entities:
@Entity({ name: "Books" })
@ObjectType()
export class Book {
@PrimaryGeneratedColumn()
@Field()
id: number;
@Column()
@Field()
title: string;
@ManyToMany(() => Author, (author: Author) => author.books)
@Field(() => [Author])
authors: Author[];
}
@Entity({ name: "Authors" })
@ObjectType()
export class Author {
@PrimaryGeneratedColumn()
@Field()
id: Number;
@Column()
@Field()
firstName: string;
@Column()
@Field()
lastName: string;
@ManyToMany(() => Book, (book: Book) => book.authors)
@JoinTable()
@Field(() => [Book])
books: Book[];
}
After setting up these entities, a third table named "authors_books_books" is created. To establish a specific relationship between authors and books, including the case where author x wrote book y, how do you populate the "authors_books_books" table with relevant data?