【发布时间】:2018-06-13 22:54:42
【问题描述】:
我想更新一条可能存在也可能不存在的记录。如果它不存在,那么什么都不会发生。
我正在为节点使用 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
)
【问题讨论】:
-
为什么标题缺少参数?我错过了什么吗?查询应该是'更新问题集答案=?,问题部分=?,标签=?,标题=?其中 question_id = ?'
-
你的问题定义也应该有 question_id?
-
@Horia 是的,修复了它
标签: node.js cassandra cql cassandra-3.0