Cassandra timeuuid列显示缓冲类型数据而不是字符串



我正在使用NodeJS Cassandra驱动程序从Cassandra timeuuid列检索数据。现在检索到的数据是缓冲区类型而不是字符串类型。我需要的数据为字符串类型

虽然仍然很难理解您期望看到的内容,但这将以更可读的格式返回您的PostedDate:

SELECT DateOf(PostedDate) FROM facehq.timeline;

此外,随着数据大小的增长,未绑定查询将变得有问题且速度很慢。因此,请确保尽可能使用WHERE子句来限定这样的查询。

我需要类似" postdate ":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd"的结果。

这听起来像你的问题是在你的node.js代码。您是如何执行查询的?GitHub项目页面上的Node.js驱动程序文档中有一个示例可能会有所帮助:

client.stream('SELECT time, val FROM temperature WHERE station_id=', ['abc'])
  .on('readable', function () {
    //readable is emitted as soon a row is received and parsed
    var row;
    while (row = this.read()) {
      console.log('time %s and value %s', row.time, row.val);
    }
  })
  .on('end', function () {
    //stream ended, there aren't any more rows
  })
  .on('error', function (err) {
    //Something went wrong: err is a response error from Cassandra
  });

DataStax文档也有一个处理timeuuid的具体示例:

client.execute('SELECT id, timeid FROM sensor', function (err, result) {
    assert.ifError(err);
    console.log(result.rows[0].timeid instanceof TimeUuid); // true
    console.log(result.rows[0].timeid instanceof Uuid); // true, it inherits from Uuid
    console.log(result.rows[0].timeid.toString());      // <- xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    console.log(result.rows[0].timeid.getDate());       // <- Date stored in the identifier
});

最新更新