Sequelize throwing invalid input syntax for integer ""

I've got a model definition here:

const Tags = sequelize.define('Tag', {
    name: {
        type: DataTypes.TEXT,
        allowNull: false,
    },
    adminOnly: {
        type: DataTypes.BOOLEAN,
        defaultValue: false,
    },
})

And 2 endpoints which create and fetch objects from the DB (psql)

const tags = await Tags.findAll()

But this line fails. What i get is

UnhandledPromiseRejectionWarning: SequelizeDatabaseError: invalid input syntax for integer: "tags"

While

await Tag.create({name: name, isStock: isStock ?? false})

works perfectly fine.

When i log in to the psql console and do select over the table i have no problems either.


Solution 1:

As your own example states, Tag.create works but Tags.findAll doesn't. Have you tried Tag.findAll()? I use init for defining models but IIRC you should match the variable name to the table name.