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
我正在使用NodeJS Cassandra驱动程序从Cassandra timeuuid列中检索数据。现在将数据检索为缓冲区类型而不是字符串类型。我需要数据作为字符串类型
1 个解决方案
#1
2
While it's still difficult to understand what you're expecting to see, this will return your PostedDate
in a more-readable format:
虽然仍然很难理解您期望看到的内容,但这将以更易读的格式返回您的PostedDate:
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.
此外,随着您的数据大小增加,未绑定的查询将变得有问题且速度慢。因此,请确保尽可能使用WHERE子句限定此类查询。
i need result like "posteddate":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd".
我需要像“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:
听起来像你的问题在你的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
});
The DataStax documentation also has a specific example for working with timeUUIDs:
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
});
#1
2
While it's still difficult to understand what you're expecting to see, this will return your PostedDate
in a more-readable format:
虽然仍然很难理解您期望看到的内容,但这将以更易读的格式返回您的PostedDate:
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.
此外,随着您的数据大小增加,未绑定的查询将变得有问题且速度慢。因此,请确保尽可能使用WHERE子句限定此类查询。
i need result like "posteddate":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd".
我需要像“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:
听起来像你的问题在你的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
});
The DataStax documentation also has a specific example for working with timeUUIDs:
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
});