gpt4 book ai didi

node.js - 从 Node js在cassandra中插入BigInt

转载 作者:搜寻专家 更新时间:2023-10-31 23:11:35 26 4
gpt4 key购买 nike

我在 cassandra 中有一个非常简单的表。
姓名:测试
:

  • id(bigint,主键)
  • name(文本)

我正在尝试使用 nodejs(使用 cassandra-driver)向其中插入值

client.execute("insert into test (id, name) values (?, ?)", [123, "dskddjls"], function (err, response) {
if (err) {
console.log("An error occured, ", err)
//...
}
else {
console.log("Added to table, ", response)
//...
}
})

插入成功完成,但是当我检查我的 cassandra 数据库时,它看起来好像我有大 int 列的垃圾值。

enter image description here

对为什么会发生这种情况有任何解释吗?

最佳答案

您需要明确指定类型作为 execute 函数的第三个参数:

client.execute("insert into test (id, name) values (?, ?)", [123, "dskddjls"], {hints: ["bigint", null]}, function (err, response) {
...
})

原因是对于一些字段cassandra driver无法猜测类型(如bigint或timestamp),所以你需要提示它。对于字符串或常规数字,它将在没有提示的情况下工作。

关于node.js - 从 Node js在cassandra中插入BigInt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39126377/

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