列ID的未设置值无效

时间:2018-01-04 08:31:20

标签: node.js cassandra cql cassandra-3.0

我想更新可能存在或可能不存在的记录。如果它不存在则不会发生任何事情。

我正在使用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});

在像

这样的表格上
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 个答案:

答案 0 :(得分:0)

  1. 更新您的问题定义以包含question_id。
  2. 更新您的查询以包含标题参数&#39;更新问题集answer =?,question_part = ?, tags = ?, title =?其中question_id =?&#39;