最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

NodeJS sequelize sqlite3 TypeError: options.logging is not a function error

网站源码admin34浏览0评论

NodeJS sequelize sqlite3 TypeError: options.logging is not a function error

NodeJS sequelize sqlite3 TypeError: options.logging is not a function error

我正在尝试使用 sqlite3 和 sequelize 创建数据库,但是当我尝试同步数据库时出现错误。 这是 syncdb.js 的代码

const Infraction = require("./infraction")


Infraction.sync({force:true})

这是数据库的代码

const Sequelize = require('sequelize')
const sequelize = require('../utils/database')

const Infraction = sequelize.define('infraction', {  logging: process.env.NODE_ENV === 'production' ? false : console.log,
    logging: false,
    id:{
        type:Sequelize.STRING,
        primaryKey:true,
        autoIncrement:true
    }, 
    userId:{
        type:Sequelize.STRING,
        allowNull:true


    },
    guildId:{
        type:Sequelize.STRING,
        allowNull:true


    },
    reason:{
        type:Sequelize.STRING,
        allowNull:false,
        defaultValue:"No reason provided."


    },
    enforcerId:{
        type:Sequelize.STRING,
        allowNull:false


    },
    type:{
        type:Sequelize.STRING,
        allowNull:false


    },
    duration:{
        type:Sequelize.INTEGER,
        allowNull:false,
        defaultValue:0


    },

});

module.exports = Infraction;

这是错误

[Running] node "xxx/discord-bot/models/syncdb.js"
xxxs/discord-bot/node_modules/sequelize/lib/sequelize.js:552
      options.logging(...args);
              ^

TypeError: options.logging is not a function
    at Sequelize.log (xxx/ds/discord-bot/node_modules/sequelize/lib/sequelize.js:552:15)
    at Query._logQuery (xxx/ds/discord-bot/node_modules/sequelize/lib/dialects/abstract/query.js:268:22)
    at Query.run (xxx/ds/discord-bot/node_modules/sequelize/lib/dialects/sqlite/query.js:182:27)
    at /xxx/discord-bot/node_modules/sequelize/lib/sequelize.js:315:28
    at async SQLiteQueryInterface.dropTable (xxx/ds/discord-bot/node_modules/sequelize/lib/dialects/abstract/query-interface.js:111:5)
    at async infraction.drop (xxxds/discord-bot/node_modules/sequelize/lib/model.js:1007:12)
    at async infraction.sync (xxx/python/ds/discord-bot/node_modules/sequelize/lib/model.js:936:7)

Node.js v18.16.0

我不知道是什么原因造成的,我尝试重新安装它并在 infraction.js 中添加一行

logging: console.log || false
但没有任何效果。 提前致谢

回答如下:
发布评论

评论列表(0)

  1. 暂无评论