How to split a Node application into files

Asked

Viewed 41 times

0

How to import model/Connection.js files to model/Tables.js

model/Connection.js

const Sequelize = require('sequelize');

const sequelize = new Sequelize('caoperdido', 'root', '', {
  host: 'localhost',
  dialect: 'mysql'
});

sequelize.authenticate().then(() => {
  console.log('Connection has been established successfully.');
}).catch(err => {
  console.error('Unable to connect to the database:', err);
});

model/Tables.js

const User = sequelize.define('user', {
    // attributes
    firstName: {
      type: Sequelize.STRING,
      allowNull: false
    },
    lastName: {
      type: Sequelize.STRING
      // allowNull defaults to true
    }
  });
  
  User.sync({ force: true }).then(() => {
    return User.create({
      firstName: 'Diovane',
      lastName: 'Maia'
    });
  });
  • Where are the images menino.png and menina.png on your computer? Since you are not giving a relative path to these images, the browser will search for them at the root of your computer/server. If the images are in the same folder as your html, you could access them as the path ./menino.png. If they were inside a directory, it would be something like ./imgs/menino.png. If they are in a directory above html, ../menino.png. Locate the images and give the appropriate path to access them.

1 answer

0


It’s a typo on the line:

hres.appendClild(img)

The method appendClild there is no right would be:

hres.appendChild(img)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.