Reputation: 155
Probably a very simple answer that I am just not finding. I have created a database of movies, I am able to find all movies simply enough with
Movie.findAll().then(function(movies){
movies.forEach(console.log);
});
What I want to do is be able to target the specific attributes of the movies as illustrated below, but I have no idea what to reference.
Movie.findAll().then(function(movies){
movies.forEach(console.log(THIS MOVIE TITLE));
});
Upvotes: 0
Views: 37
Reputation: 122
There is a another way to get movie names.
You can specify the attribute names so you will get only those columns.
Movie.findAll({
attributes: ['title']
}).then((movies) => {
});
By this, you get the array of an object which contains movie titles.
Upvotes: 0
Reputation: 536
Simply find the title of each movie inside the movies array.
Might be like this:
Movie.findAll().then(function(movies){
movies.forEach(movie => console.log(movie.title));
});
Upvotes: 1