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

RangeError [ERR

运维笔记admin8浏览0评论

RangeError [ERR

RangeError [ERR

我要插入的值出现此范围错误。

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
  }
}

YodleeTransaction模型:

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')中手动写出更新查询。

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论