在Cassandra中使用用户定义的types和nodejs

我正在尝试在Cassandra中使用用户定义的types和nodejs。 按照文档,我成功地设法在cqlsh中执行( https://www.datastax.com/documentation/cql/3.1/cql/cql_using/cqlUseUDT.html )。 我设法在cqlsh中插入项目,但不能使用cassandra-driver模块。

我明白他们是一些错综复杂的使用JavaScript( http://www.datastax.com/documentation/developer/nodejs-driver/1.0/nodejs-driver/reference/nodejs2Cql3Datatypes.html ),我已经尝试了不同的select提供,但我不能得到它的工作。

这是我的审判和他们的错误信息:

 var insertQuery = 'INSERT INTO mykeyspace.users (id, name) VALUES (?, ?)' client.execute(insertQuery, ['62c36092-82a1-3a00-93r1-46196ee77204', { firstname: 'paul', lastname: 'jacques'}], {hints: ['uuid', 'map<text, text>']}, function(err) { console.log(err);}) 

{ name: 'ResponseError', message: 'Not enough bytes to read 0th field java.nio.HeapByteBuffer[pos=0 lim=9 cap=9]', info: 'Represents an error message from the server', code: 8704, query: 'INSERT INTO mykeyspace.users (id, name) VALUES (?, ?)' }

 client.execute(insertQuery, ['62c36092-82a1-3a00-93r1-46196ee77204', { firstname: 'paul', lastname: 'jacques'}], { prepare: true }, function(err) { console.log(err);}) { [TypeError: Not a valid blob, expected Buffer obtained { firstname: 'paul', lastname: 'jacques' }] query: 'INSERT INTO mykeyspace.users (id, name) VALUES (?, ?)' } 

那么使它正常工作的正确语法是什么?

NB。 我正在使用cassandra 2.1.1

DataStax Node.js驱动程序不支持用户定义的types,所以驱动程序将不能相应地序列化数据。

您可以在CQL中使用json符号来访问各个字段。 例如,像下面这样的查询将起作用:

 SELECT addr.street, addr.city FROM location WHERE id=?; 

要么

 UPDATE SET addr['street'] = ?, addr['city'] = ? WHERE id = ?