Firestore Database Joins

I have a question relating to the data in a firestore database. How would I realize a n:m relation between two collections? For example I have a collection books and a collection genres. Normally I would store the books as a sub collection in the documents of the genre collection. But what if one book can also have more than one genre?

I know it from the relational database that there is a reference key in one of the tables which refers to another? Does this work here the same?
How does the query in SwiftUI look like?

Thanks in advance.