I am using sequelize cli with sequelize to generate a seeder file for a many to many join table
Here I have Users and Collections and User_Collections as the join table I have already created seeder files for Users and Collections but I want to create a seeder file for the join table . How do I dynamically access the id of the row in User or Collection so that I can insert that value in the join table bulkinsert
Users:
module.exports = {
up: (queryInterface, Sequelize) => queryInterface.bulkInsert('Users', [ {
first_name: 'John',
last_name: 'Doe',
email: '[email protected]',
password: 'testme',
createdAt: new Date(),
updatedAt: new Date(),
}], {}),
down: (queryInterface, Sequelize) => queryInterface.bulkDelete('Users', null, {}),
};
Collection
module.exports = {
up: (queryInterface, Sequelize) => queryInterface.bulkInsert('Collections', [{
collection_name: 'Test Collection1',
createdAt: new Date(),
updatedAt: new Date(),
}, {
collection_name: 'Test Collection2',
createdAt: new Date(),
updatedAt: new Date(),
}, {
collection_name: 'Test Collection3',
createdAt: new Date(),
updatedAt: new Date(),
}]),
down: (queryInterface, Sequelize) => queryInterface.bulkDelete('Collections', null, {}),
};