我如何让Helenus返回CQL查询的实际值?

我使用Helenus的Node.js连接到Cassandra DB。

我有一个查询:SELECT score FROM team_scores WHERE team_name ='foo'

从cqlsh运行时,我得到的结果如下所示:

score ------- 10 

然后,我使用cqlVersion 3.0.0将查询移动到Node和Helenus。 当我运行这个代码:

 pool.cql("SELECT score FROM team_scores WHERE team_name = 'foo'", function(err, results){ console.log(results); }); 

控制台报告:

 [ <Row: Key: 'foo', ColumnCount: 1, Columns: [ 'score' ]> ] 

我错过了什么让Helenus回报我的分数的实际价值,而不是似乎返回?

结果实际上是行对象的列表。 你可能看到了toString实现的结果。

这里有一些很好的代码来注销select的结果:

 results.forEach(function(row){ //all row of result row.forEach(function(name,value,ts,ttl){ //all column of row console.log(name,value,ts,ttl); }); }); 

你可以阅读helenus github 。 查看关于行对象的底部的东西。

 results.forEach(function(row){ var score = row.get('score').value; console.log(score); //will give you 10 });