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 Getting Started with Sequelize Define a Model

Sequelize Define a model

const sequelize = new Sequelize({...});

Im getting an error whenever I type the " ... ".Also what does the dots do?

Here is my full code:

const Sequelize = require('sequelize');
const sequelize = new Sequelize({...});

const sequelize = new Sequelize({
  dialect: 'sqlite',
  storage: 'movies.db',
});

(async () => {
  try {
    await sequelize.authenticate();
    console.log('Connection to the database successful!');
  } catch (error) {
    console.error('Error connecting to the database: ', error);
  }
})();

class Movie extends Sequelize.Model {}
Movie.init({ ... });

(async () => {
  await sequelize.sync({ force: true });

  try {
    const movie = await Movie.create({
      title: 'Toy Story',
    });
    console.log(movie.toJSON());

  } catch (error) {
    console.error('Error connecting to the database: ', error);
  }
})();```
Reggie Williams
Reggie Williams
Treehouse Teacher

Hey Azzie Fuzzie the ... are just placeholders for values you'll update later. Which line are you getting the error on?

Hey, Reggie Williams it says unexpected token by the last curly bracket on line 2

1 Answer

These dots represents folded or collapsed code from previous step. sequelize should look like this:

const sequelize = new Sequelize({
  dialect: 'sqlite',
  storage: 'movies.db'
});

thank you for this! I though I only had to created this once. I deleted it after the first step!