Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSai Perez
Full Stack JavaScript Techdegree Student 13,388 PointsStill not working: "Download a completed example of the "many-to-many relationship" challenge."
I'm unable to download the completed example of the many-to-many relationship in order to figure out how to do it. I read the documentation for using a many to many association and attempted this:
movie.js
Movie.belongsToMany(models.Person, {
through: 'ActorMovies',
as: 'actor',
foreignKey: {
fieldName: 'actorPersonId',
allowNull: false,
},
});
person.js
Person.belongsToMany(models.Movie, {
through: 'ActorMovies',
as: 'actor',
foreignKey: {
fieldName: 'actorPersonId',
allowNull: false,
},
});
app.js
// Add Movies to the Database
console.log('Adding movies to the database...');
const movieInstances = await Promise.all([
Movie.create({
title: 'The Iron Giant',
releaseYear: 1999,
directorPersonId: bradBird.id,
actorPersonId: vinDiesel.id,
}),
Movie.create({
title: 'The Incredibles',
releaseYear: 2004,
directorPersonId: bradBird.id,
actorPersonId: craigTNelson.id,
}),
]);
Please help.
1 Answer
Travis Alstrand
Treehouse TeacherHey Sai Perez !
I'm very sorry about that inconvenience, there was a strange issue with the download link, but it has been fixed! You can try downloading the folder again and compare that with what you have now!
If you still have any questions after comparing your code definitely feel free to reach back out on this post, I'll keep my eyes open just in case
Sai Perez
Full Stack JavaScript Techdegree Student 13,388 PointsSai Perez
Full Stack JavaScript Techdegree Student 13,388 PointsThank you!
Travis Alstrand
Treehouse TeacherTravis Alstrand
Treehouse TeacherYou're very welcome!