egg-mysql bigint被约分

Created on 13 Oct 2017  ·  9Comments  ·  Source: eggjs/egg

数据库player表中guid为bigint类型

代码:
let result = yield client.get('player', { playername: ctx.request.body.player_name });

result结果:
RowDataPacket {
guid: 4035837130283371500,

然而 实际的guid是: 4035837130283371672

not follow template

Most helpful comment

找到了,有选项,
supportBigNumbers = true;
bigNumberStrings = true;

All 9 comments

超过 Number.MAX_SAFE_INTEGER 了啊,这是 JS 本身的限制,只能改为 String。

@atian25 目前这个表是线上的表,没办法修改字段类型,还有其他程序在使用,有其他的读取办法么?

  • 用字符串
  • 用第三方的 bigInt 库
  • 关注 ES 的 bigInt 提案

找到了,有选项,
supportBigNumbers = true;
bigNumberStrings = true;

找到了,有选项,
supportBigNumbers = true;
bigNumberStrings = true;

麻烦问一下 这个配置选项在哪里配置需要安装什么库嘛?

@meicx egg 的配置文件里,不需要安装其他库

请问下可以不返回RowDataPacket形式的吗?

请问下可以不返回RowDataPacket形式的吗?

https://cnodejs.org/topic/575f5f23f2d6aeb302e8a68c
使用bing搜索引擎成功找到了相关资料~

请问下可以不返回RowDataPacket形式的吗?

https://cnodejs.org/topic/575f5f23f2d6aeb302e8a68c
使用bing搜索引擎成功找到了相关资料~

地址过期了
不过可以直接
搜索 node RowDataPacket

      hat = await mysql.query('SELECT * FROM `hat_lists` WHERE (`device_id` = ? or `id` = ?) LIMIT 0, 1', [data.device_id, data.id])

      console.log(hat);
      console.log(hat[0].device_id);
Was this page helpful?
0 / 5 - 0 ratings