How to allow null for a foreign key? I have an association throughand belongsToMany:
Shelf
belongsToMany(Book, { through: Library, as: "Books"});
Book
belongsToMany(Shelf, { through: Library, as: "Shelves"});
Library
section: DataTypes.STRING,
I would like to write zero in bookIdin Library:
Library.create({
section: "blah",
bookId: null,
shelfId: 3
});
Since Sequelize automatically creates bookIdand shelfIdin the connection table Library, as if I said that I want to allow nullin the bookIdfile foreignkey in Library?
source
share