node.js - RangeError [ERR_OUT_OF_RANGE]:“值”的值超出范围。它必须 >= 0 和 <= 4294967295。收到 9433906525
问题描述
对于我未插入的值,我收到此范围错误。
const createTransaction = async (yodleeAccountId, transaction) => {
try {
const savedRecord = await YodleeTransaction.create({
YodleeAccountID: 373,
YodleeID: 1887219837,
Amount: 40518.32,
AmountCurrency: 'USD',
BaseType: 'CREDIT',
Container: 'bank',
PostDate: '2016-03-19',
OriginalDescription: 'info about transaction',
SimpleDescription: 'info',
CategoryID: '2',
Category: 'giving idk',
CategoryType: 'the important type',
})
console.log('post create')
return savedRecord
} catch (error) {
console.error('error finally caught', error)
return error
}
}
Yodlee交易模型:
module.exports = (sequelize, type) => {
return sequelize.define(
'YodleeTransaction',
{
ID: { type: type.BIGINT, primaryKey: true, autoIncrement: true },
YodleeAccountID: { type: type.BIGINT, allowNull: false },
YodleeID: { type: type.BIGINT, allowNull: false },
Amount: { type: type.DECIMAL(12, 2), allowNull: false },
AmountCurrency: { type: type.STRING(3) },
BaseType: { type: type.STRING(25), allowNull: false },
Container: { type: type.STRING(50) },
PostDate: { type: type.DATE, allowNull: false },
OriginalDescription: { type: type.STRING(800) },
SimpleDescription: { type: type.STRING(500) },
CategoryID: { type: type.INTEGER },
Category: { type: type.STRING(50) },
CategoryType: { type: type.STRING(50) },
},
{ freezeTableName: true, tableName: 'YodleeTransaction' }
)
}
错误:
RangeError [ERR_OUT_OF_RANGE]:“值”的值超出范围。它必须 >= 0 和 <= 4294967295。收到 9433906525
我知道 9433906525 以某种方式基于 ,Amount
因为当我更改 时Amount
,错误消息中的值会更改。例如,如果我将金额从 40518.32 更改为 8989.33,则收到的新值是 10728568304。新错误:
RangeError [ERR_OUT_OF_RANGE]:“值”的值超出范围。它必须 >= 0 和 <= 4294967295。收到 10728568304
解决方案
这似乎是 Sequelize 中的一个错误。异步执行过多的插入或更新会导致这种情况发生。我不知道具体如何解决这个问题,但我可以告诉你如何解决它。
上述创建错误的解决方案是使用bulkCreate
对象数组并将其传递给它。
如果您使用 t-sql 进行更新,则 Sequelize 不提供bulkUpdate
方法。所以你应该手动写出里面的更新查询sequelize.query('UPDATE YodleeTransaction SET Amount=344.88')
。
推荐阅读
- amazon-web-services - 为什么 NumberOfMessagesDeleted > NumberOfMessagesSent
- html - 使整个 html 按钮可点击
- github - 除非 PR 有“Ready For Merge”标签,否则不要启用绿色合并按钮
- sql - 更新 JSON 字符串中的值
- c# - ASP .NET Cookie 过期发布方法 + Cookie 过期
- sql-server - 在实体框架工作核心 3.1 中使用存储过程插入数据
- python - 尝试移动数据框中列出的文件时出现 FileNotFoundError
- c - 编写迭代函数来计算数学序列
- hive - 我们可以在单个查询中创建多个分区和存储桶,您能提供语法吗?
- python - Python多处理管理器修剪一些方法