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

编程入门 行业动态 更新时间:2024-10-07 06:46:19

NodeJS sequelize sqlite3 <a href=https://www.elefans.com/category/jswz/34/1771446.html style=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
但没有任何效果。 提前致谢

回答如下:

更多推荐

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

本文发布于:2024-05-30 06:58:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1770229.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TypeError   NodeJS   sequelize   function   error

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!