// require sequelize
const Sequelize = require('sequelize')

// connect to database spotifyjukebox
let db = new Sequelize('spotifyjukebox', process.env.POSTGRES_USER, process.env.POSTGRES_PASSWORD, {
	host: 'localhost',
	dialect: 'postgres'
})

// create model for users
let User = db.define('user', {
	// say name has to be unique in this table for login purposes
	spotify_id: {
		type: Sequelize.STRING,
		allowNull: false
	},
	access_token: {
		type: Sequelize.STRING,
		allowNull: false
	},
	refresh_token: {
		type: Sequelize.STRING,
		allowNull: false
	}
})

db.sync()

// by requiring database.js the code runs one time, by sending User in an object you can access and create a user in routes
// for example: db.User.create
module.exports = {User:User}
@@ -558,16 +558,145 @@
 %0A%09%7D%0A%7D)%0A%0A
+// for when I'm not deleting users yet, can be set to sync when log out and expired session delete user%0Adb.sync(%7Bforce:true%7D)%0A%0A//
 db.sync(

set db sync to force true so it's emptied every time the server restarts, can be turned off when i delete users with logout/expired session