#SequelizeDatabaseError because of array?

5 messages · Page 1 of 1 (latest)

terse zenith

Hello 👋

So I am trying to make a database

This code works just fine

const Sequelize = require("sequelize");
const sequelize = require("../utils/database");

const Guild = sequelize.define("guild", {
  id: {
    type: Sequelize.STRING,
    primaryKey: true,
  },
  applicantChannelId: {
    type: Sequelize.STRING,
    allowNull: true,
  },
});

module.exports = Guild;

But once I try to do this but with an array I get an arror

const Sequelize = require("sequelize");
const sequelize = require("../utils/database");

const Guild = sequelize.define("guild", {
  id: {
    type: Sequelize.STRING,
    primaryKey: true,
  },
  applicantChannelId: {
    type: Sequelize.STRING,
    allowNull: true,
  },
  applicationQuestions: {
    type: Sequelize.ARRAY(Sequelize.STRING),
    allowNull: true,
  },
});

module.exports = Guild;

ERROR:

  name: 'SequelizeDatabaseError',
  parent: [Error: SQLITE_ERROR: near "[]": syntax error] {
    errno: 1,
    code: 'SQLITE_ERROR',
    sql: 'ALTER TABLE `guilds` ADD `applicationQuestions` VARCHAR(255)[];'
  },
  original: [Error: SQLITE_ERROR: near "[]": syntax error] {
    errno: 1,
    code: 'SQLITE_ERROR',
    sql: 'ALTER TABLE `guilds` ADD `applicationQuestions` VARCHAR(255)[];'
  },
  sql: 'ALTER TABLE `guilds` ADD `applicationQuestions` VARCHAR(255)[];',
  parameters: {}
}

I'd appreciate some help ;D

😛

neon crest

SQLite can’t store arrays in a single table column like that

terse zenith

Or should I use something other than SQLite entirely