I'm looking to work with cassandra using cassandra-driver in nodejs.
When I execute a simple query like this:
const results = await chatDbClient.execute('SELECT * FROM chat_db.messages LIMIT 5');
return results.rows;
I receive the following results:
Row from Keyspaces Row {
user_from: [Long],
user_to: [Long],
message_id: [TimeUuid],
body: 'c'
}
[
Row {
user_from: Long { low: 1, high: 0, unsigned: false },
user_to: Long { low: 2, high: 0, unsigned: false },
message_id: TimeUuid {
buffer: <Buffer f0 c2 49 b1 fd a4 11 ea 8b 02 85 9f 38 c2 63 74>
},
body: 'c'
},
Row {
user_from: Long { low: 1, high: 0, unsigned: false },
user_to: Long { low: 2, high: 0, unsigned: false },
message_id: TimeUuid {
buffer: <Buffer f0 c2 22 a3 fd a4 11 ea bc 5e cb 7d 37 47 a0 82>
},
body: 'f'
},
Row {
user_from: Long { low: 1, high: 0, unsigned: false },
user_to: Long { low: 2, high: 0, unsigned: false },
message_id: TimeUuid {
buffer: <Buffer f0 c2 22 a2 fd a4 11 ea bc 5e cb 7d 37 47 a0 82>
},
body: 'e'
},
Row {
user_from: Long { low: 1, high: 0, unsigned: false },
user_to: Long { low: 2, high: 0, unsigned: false },
message_id: TimeUuid {
buffer: <Buffer f0 c1 fb 95 fd a4 11 ea a3 0f 3b e9 2e a5 73 87>
},
body: 'd'
},
Row {
user_from: Long { low: 1, high: 0, unsigned: false },
user_to: Long { low: 2, high: 0, unsigned: false },
message_id: TimeUuid {
buffer: <Buffer f0 c1 fb 94 fd a4 11 ea a3 0f 3b e9 2e a5 73 87>
},
body: 'm'
}
]
But if I execute the query directly from aws dashboard for testing purpose I receive this:
Why in my app the result has such a strange format?
Tnx in advance
问题解决了,读取数据就够用了:toString()
results.rows[i].user_to.toString()
在您的应用中尝试以下操作
console.log(result.rows[0].timeid instanceof TimeUuid);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.