Seeking assistance with Sequelize ORM in express.js, I have successfully implemented a many-to-many relationship between two tables.
To simplify my query, imagine the tables as Users, Books, and UserBooks where UserBooks contains UserId, BookId, and an extra column (let's call it NoOfTimesRead).
My goal is to achieve something like this:
user.getBooks({
where: {
"userBooks.NoOfTimesRead": 0
}
});
When I use:
user.getBooks();
It works fine and returns all books, but I am struggling to figure out how to filter by the additional column on the joining table.
I hope this explanation is clear. Thank you for your help!