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 trial

JavaScript Using SQL ORMs with Node.js Defining Models Go Further with Models

Boolean values not showing up properly

These are my values for isAvailableOnVHS in app.js. One is TRUE and one is FALSE. Nevertheless, they are both saved as FALSE in my DB.

APP.JS: //Instance of the Movie class respresents a database row const movie = await Movie.create({ title: 'Once Upon A Time in Hollywood', runtime: 160, releaseDate: '2019-07-24', isAvailableOnVHS: false, }); console.log(movie.toJSON());

 //New entry
 const movie2 = await Movie.create({
   title: 'Shawshank Redemption',
   runtime: 142,
   releaseDate: '1995-01-06',
   availableOnVHS: true,
 });
 console.log(movie2.toJSON());

CONSOLE.LOG in Visual Studio Code: both isAvailableOnVHS values are logged as FALSE.

{ id: 1, title: 'Once Upon A Time in Hollywood', runtime: 160, releaseDate: '2019-07-24', isAvailableOnVHS: false, updatedAt: 2020-04-12T16:29:58.792Z, createdAt: 2020-04-12T16:29:58.792Z } { isAvailableOnVHS: false, id: 2, title: 'Shawshank Redemption', runtime: 142, releaseDate: '1995-01-06', updatedAt: 2020-04-12T16:29:58.816Z, createdAt: 2020-04-12T16:29:58.816Z }

QUESTION: In my DB Browser they also both show 0 (false). I wonder if anybody could help me to understand why. I refreshed and restarted couple of times, tried to change the values, but it still only shows one boolean value at a time.

This is my model for a movie entry isAvailableOnVHS property:

isAvailableOnVHS: { type: Sequelize.BOOLEAN, allowNull: false, // disallows null defaultValue: false, //set default value },

Thank you for your help and time and happy debugging to everyone:)

1 Answer

It seems to always do the magic when I post a question. I noticed I misspelled the property 'isAvailableOnVHS' in the second movie entry, so now everything is running properly.

I wrote 'availableOnVHS' instead of the correct 'isAvailableOnVHS' :) My bad. But thank you. Posting this question actually helped me:) Just getting it out there outloud helps. I must buy myself a rubber duck for debugging talks:)