discordjs | SQLITE表-没有列-

时间:2020-06-02 22:33:00

标签: node.js sqlite discord.js

我不知道是否已经回答了,所以我问。 (我尝试过查找,但这全部用于android应用和Java而不是JavaScript)

我遇到一个问题,SQlite表示我的表没有我创建的特定列。

错误消息: DatabaseError [SequelizeDatabaseError]: SQLITE_ERROR: table rosters has no column named addedBy

但是,我在这里:

const Roster = sequelize.define('roster', {
    // The player being added
    player: {
        type: Sequelize.STRING,
        unique: true,
    },
    // The team the player is getting added to
    team: Sequelize.STRING,
    // The person who added the player to the roster
    addedBy: Sequelize.STRING,
});

在这里:

if(command === 'add') {
        // Add play to a team on the roster

        const splitArgs = commandArgs.split(' ');
        const playerName = args[0];
        const teamName = args[1];

        try {
            const roster = await Roster.create({
                player: playerName,
                team: teamName,
                addedBy: message.author.username,
            });
            return message.channel.send(`Player ${roster.playerName} has been added to ${roster.teamName}.`);
        } catch (e) {
            if(e.name === 'SequelizeUniqueConstraintError') {
                return message.channel.send('That player is already on a team!');
            }
            console.error(e);
            return message.channel.send('Something went wrong adding that player to a team.');
        }

    }

我对使用sequelize / sqlite还是很陌生,所以我遵循以下指南:https://discordjs.guide/sequelize/#a-simple-tag-system,同时我尝试做自己的事情以进一步加深我的理解。

0 个答案:

没有答案