node.js - 列 ID 的未设置值无效

标签 node.js cassandra cql cassandra-3.0

我想要更新一条可能存在也可能不存在的记录。如果它不存在,那么什么都不会发生。

<小时/>

我正在为 Node 使用 cassandra 驱动程序,收到错误

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ResponseError: Invalid unset value for column question_id

当尝试做类似的事情时

let question = {
  question_part: ['How many times has Leicester Tigers won the Heineken Cup?'],
  answer: ['2'],
  tags: ['competition', 'rugby'],
  title: 'Rugby pub quiz'
};

let query = 'update question set answer = ?, question_part = ?, tags = ?, title = ? where question_id = ?';
const params = [question.answer, question.question_part, question.tags, question.title, question.question_id];
cassandraClient.execute(query, params, {prepare: true});

在 table 上

CREATE TABLE question (
    question_id timeuuid PRIMARY KEY,
    answer list<text>,
    cakes int,
    created timestamp,
    creator_display_name text,
    creator_id text,
    difficults int,
    dislikes int,
    drops int,
    easies int,
    favorites int,
    impossibles int,
    last_activity timestamp,
    likes int,
    question_part list<text>,
    right_answers int,
    tags set<text>,
    title text,
    views int,
    wrong_answers int
)

最佳答案

  1. 更新您的问题定义以包含 Question_id。
  2. 更新您的查询以包含标题参数“更新问题集答案 = ?, Question_part = ?, Tags = ?, title = ?”其中 Question_id = ?'

关于node.js - 列 ID 的未设置值无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48091387/

相关文章:

python - 多节点 Cassandra 集群和不一致的客户端读取请求

c# - 无法使用 DataStax C# 驱动程序从 Cassandra 获取值

hadoop - OLAP 实时查询海量数据 - 选项

java - 使用 Cassandra 和 Solr 的网站最有效的架构?

cassandra - 为什么 Cassandra 中的二级索引效率较低?

Cassandra - 列族存在,但通过描述或 OpsCenter 不可见

node.js - Mongoose 模式/模型中的自定义构造函数

javascript - 如何同时使用http服务器和socket连接

node.js - 如何忽略 'firebase-admin appears to have been installed in an unsupported environment.'?

node.js - Axios - 使用 url + 变量发送 get 请求