gpt4 book ai didi

node.js - cassandra timeuuid 列显示由字符串插入的缓冲区类型数据

转载 作者:太空宇宙 更新时间:2023-11-03 21:59:04 25 4
gpt4 key购买 nike

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

最佳答案

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

SELECT DateOf(PostedDate) FROM facehq.timeline;

此外,随着数据大小的增长,未绑定(bind)的查询将变得有问题且缓慢。因此,请确保尽可能使用 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
});

关于node.js - cassandra timeuuid 列显示由字符串插入的缓冲区类型数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32332696/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com