Prorammer81
Prorammer81

Reputation: 198

cassandra timeuuid columns showing buffer type data insted of string

I am retrieving data from Cassandra timeuuid column using NodeJS Cassandra driver. Now the data retrieved as buffer type instead of string type. I need the data as string type

Upvotes: 3

Views: 1098

Answers (1)

Aaron
Aaron

Reputation: 57843

While it's still difficult to understand what you're expecting to see, this will return your PostedDate in a more-readable format:

SELECT DateOf(PostedDate) FROM facehq.timeline;

Also, as your data grows in size, unbound queries will become problematic and slow. So make sure you qualify queries like this with a WHERE clause whenever possible.

i need result like "posteddate":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd".

It sounds to me like your issue is in your node.js code. How are you executing your query? The Node.js driver documentation on the GitHub project page has an example that may help:

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
  });

The DataStax documentation also has a specific example for working with timeUUIDs:

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
});

Upvotes: 2

Related Questions