错误:不匹配的列名/值cassandra

时间:2017-05-18 16:01:21

标签: node.js express cassandra

插入查询Node.js:

router.post('/recent_activities', function(req, res, next) {var body =req.body;
console.log(body);
console.log( body.id + body.setid);

var query ="Insert into recent_activities (id,setid,companyid,activity_name,activity_date,activity_by,activity_group) values (? , ?, ?, ?, dateof(now()), ?)"
client.execute(query,[body.id,body.setid,body.companyid,body.activity_name,body.activity_by,'fsdf'], function(err, result) {
    if (err) {
        throw err;
    } else {
        console.log('success!');
    }
    });
res.json({ id:201, message: 'All Success' });   });

错误消息:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Unmatched column names/values
    at ResponseError.DriverError (/apps/node_cassandra/node_modules/cassandra-driver/lib/errors.js:14:19)
    at new ResponseError (/apps/node_cassandra/node_modules/cassandra-driver/lib/errors.js:51:24)
    at FrameReader.readError (/apps/node_cassandra/node_modules/cassandra-driver/lib/readers.js:317:13)
    at Parser.parseBody (/apps/node_cassandra/node_modules/cassandra-driver/lib/streams.js:194:66)
    at Parser._transform (/apps/node_cassandra/node_modules/cassandra-driver/lib/streams.js:137:10)
    at Parser.Transform._read (_stream_transform.js:179:10)
    at Parser.Transform._write (_stream_transform.js:167:12)
    at doWrite (_stream_writable.js:226:10)
    at writeOrBuffer (_stream_writable.js:216:5)
    at Parser.Writable.write (_stream_writable.js:183:11)

1 个答案:

答案 0 :(得分:1)

您的列列表中指定了7列,但值列表中只有6列。

7列

(id, setid, companyid, activity_name, activity_date, activity_by, activity_group)

6个值

(? , ?, ?, ?, dateof(now()), ?)

您的值列表应如下所示吗?

(?, ?, ?, ?, dateof(now()), ?, ?)