显示缓冲区类型数据的 cassandra timeuuid 列 insted of string
cassandra timeuuid columns showing buffer type data insted of string
我正在使用 NodeJS Cassandra 驱动程序从 Cassandra timeuuid 列检索数据。现在,数据检索为缓冲区类型而不是字符串类型。我需要字符串类型的数据
虽然仍然难以理解您期望看到的内容,但这将 return 您的 PostedDate
以更易读的格式:
SELECT DateOf(PostedDate) FROM facehq.timeline;
此外,随着数据量的增加,未绑定的查询将变得有问题且速度变慢。因此,请确保尽可能使用 WHERE 子句限定此类查询。
i need result like "posteddate":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd".
在我看来,您的问题似乎出在 node.js 代码中。您如何执行查询? Node.js driver documentation on the GitHub project page 有一个可能有帮助的例子:
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 文档也有针对 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
});
我正在使用 NodeJS Cassandra 驱动程序从 Cassandra timeuuid 列检索数据。现在,数据检索为缓冲区类型而不是字符串类型。我需要字符串类型的数据
虽然仍然难以理解您期望看到的内容,但这将 return 您的 PostedDate
以更易读的格式:
SELECT DateOf(PostedDate) FROM facehq.timeline;
此外,随着数据量的增加,未绑定的查询将变得有问题且速度变慢。因此,请确保尽可能使用 WHERE 子句限定此类查询。
i need result like "posteddate":"f6ca25d0-ffa4-11e4-830a-b395dbb548cd".
在我看来,您的问题似乎出在 node.js 代码中。您如何执行查询? Node.js driver documentation on the GitHub project page 有一个可能有帮助的例子:
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 文档也有针对 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
});