1

I'm using Sequelize (6.3.0) with sqlite3 (4.2.0) for my database and I'm trying to define the following model :

this.define("giveaways", {
            channel: {
                type: Sq.STRING,
                allowNull: false
            },
            message: {
                type: Sq.STRING,
                allowNull: false
            },
            name: {
                type: Sq.STRING,
                allowNull: false
            },
            end: {
                type: Sq.DATE,
                allowNull: false
            },
            participating: {
                type: Sq.ARRAY(Sq.STRING),
                allowNull: false,
                defaultValue: []
            },
            winnersCount: {
                type: Sq.NUMBER,
                allowNull: false
            },
            winners: {
                type: Sq.ARRAY(Sq.STRING),
                allowNull: false,
                defaultValue: []
            },
            finished: {
                type: Sq.BOOLEAN,
                allowNull: false,
                defaultValue: false
            },
            host: {
                type: Sq.STRING,
                allowNull: false
            }

        });

It is supposed to be defined when process starts, but I get the following error :

(node:22440) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: SQLITE_ERROR: near "[]": syntax error

And of course whenever I try to do any action to this table, I get follow error :

(node:22440) UnhandledPromiseRejectionWarning: SequelizeDatabaseError: SQLITE_ERROR: no such table: giveaways

I guess the problem comes from "participating" and "winners" rows that are using the ARRAY data type..

Thanks for your help

1 Answer 1

4

Let me quote the manual:

ARRAY()

An array of type, e.g. DataTypes.ARRAY(DataTypes.DECIMAL). Only available in postgres.

(Emphasis mine.)

So, you cannot use the ARRAY datatype with SQLite3, only with PostgreSQL as your backend.

You can also look at the SQLite3 docs - SQLite3 doesn't have an array-like datatype that Sequelize could use to implement ARRAY.

On a side note: You should check your code to see why you are getting unhandled promise rejections. It sounds as if you are not handling async errors correctly. Maybe missing .catch on an asynchronous call?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.