gpt4 book ai didi

node.js - NodeJs - Sequelize - 无法识别的属性数据类型

转载 作者:行者123 更新时间:2023-12-03 22:25:50 25 4
gpt4 key购买 nike

我正在尝试为我的 dcauser 表制作模型。我被卡住了,因为它返回一个错误“无法识别的属性数据类型”。现在我不知道我是否在数据库中搞砸了一些东西,或者是 sequelize 无法与我的数据库正常工作,或者我是否在下面的代码中搞砸了一些东西。我遵循了一些指南,但我总是遇到上面提到的相同问题。

var Sequelize = require('sequelize');
var sequelize = new Sequelize('postgres://postgres:xpwdx@localhost:xportx/xdbx');


const UserSchema = sequelize.define(
'dcauser',
{
userid: {
type: Sequelize.Integer,
allowNull: false,
}
}
);


module.exports = UserSchema;

我收到以下错误:
C:\Users\luka\source\repos\dcaBotManager\node_modules\sequelize\lib\model.js:1005
throw new Error(`Unrecognized datatype for attribute "${this.name}.${name}"`);
^

Error: Unrecognized datatype for attribute "dcauser.userid"
at C:\Users\luka\source\repos\dcaBotManager\node_modules\sequelize\lib\model.js:1005:15
at C:\Users\luka\source\repos\dcaBotManager\node_modules\lodash\lodash.js:13401:38
at C:\Users\luka\source\repos\dcaBotManager\node_modules\lodash\lodash.js:4905:15
at baseForOwn (C:\Users\luka\source\repos\dcaBotManager\node_modules\lodash\lodash.js:2990:24)
at Function.mapValues (C:\Users\luka\source\repos\dcaBotManager\node_modules\lodash\lodash.js:13400:7)
at Function.init (C:\Users\luka\source\repos\dcaBotManager\node_modules\sequelize\lib\model.js:1001:28)
at Sequelize.define (C:\Users\luka\source\repos\dcaBotManager\node_modules\sequelize\lib\sequelize.js:428:11)
at Object.<anonymous> (C:\Users\luka\source\repos\dcaBotManager\src\models\user.model.js:14:30)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\luka\source\repos\dcaBotManager\src\models\index.js:2:23)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\luka\source\repos\dcaBotManager\src\config\passport.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)

最佳答案

integer 关键字必须大写

{
userid: {
type: Sequelize.INTEGER,
allowNull: false,
}
}

关于node.js - NodeJs - Sequelize - 无法识别的属性数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61599638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com