You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
638 B

  1. const Sequelize = require('sequelize')
  2. const sequelize = new Sequelize('postgres://johntitor@localhost:5432/mydb')
  3. sequelize.authenticate().then(() => {
  4. console.log('Connection has been established successfully.')
  5. })
  6. .catch(err => {
  7. console.error('Unable to connect to the database:', err)
  8. })
  9. const Posts = sequelize.define('posts', {
  10. title: {
  11. type: Sequelize.STRING,
  12. allowNull: false
  13. },
  14. username: {
  15. type: Sequelize.STRING,
  16. allowNull: false
  17. },
  18. arttext: {
  19. type: Sequelize.STRING,
  20. allowNull: false
  21. },
  22. })
  23. Posts.sync()
  24. module.exports = {sequelize, Posts}