Sequelize not inserting into mysql database

20 Views Asked by At

using this code here

const express = require('express');
const app = express();

const db = require('./models');

const { Item } = require('./models'); 

app.get('/select', (req, res) => {
    res.send('select')
});

app.get('/insert', (req, res) => {
    Item.create({
        name: 'Juan',
        price: 100
    }).catch((err) => {
        console.log(err);
    });
});

app.get('/delete', (req, res) => {
    res.send('delete')
});


db.sequelize.sync().then((req) => {
    app.listen(3000, () => {
        console.log('Server is running');
    });
});

i am not getting anything added to the database. what i get is WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = 'Items' AND TABLE_SCHEMA = 'wishlist_app' Executing (default): SHOW INDEX FROM Items FROM wishlist_app Server is running

i tried different error and catch handling, didnt work. i expected data to be added to database or to get an error. i got neither

0

There are 0 best solutions below