简体   繁体   English

如何在Node.js Cassandra驱动程序中为查询设置键空间?

[英]How to set a keyspace for a query in nodejs cassandra driver?

I am trying to make a query with cassandra-driver, specifying the keyspace as an option, but am getting the error "No keyspace has been specified." 我正在尝试使用cassandra-driver进行查询,将键空间指定为选项,但是出现错误“未指定键空间”。

I am using the following code 我正在使用以下代码

connection = new driver.Client({ contactPoints: ['abc'] });

connection.execute(query, { keyspace: 'system_schema' })

Can anyone help me understand what I'm missing? 谁能帮助我了解我所缺少的吗?

You need to specify keyspace as option to the Client , in your case it should be as following: 您需要将keyspace指定为Client选项,在这种情况下,它应如下所示:

connection = new driver.Client({contactPoints: ['abc'], keyspace: 'system_schema'});
connection.execute(query, queryOptions, callback);

See documentation on ClientOptions & QueryOptions . 请参阅ClientOptionsQueryOptions的文档。

If you need to access table in another namespace, then you need to use fully qualified table name in the query - as keyspace_name.table_name 如果需要访问另一个命名空间中的表,则需要在查询中使用标准表名-作为keyspace_name.table_name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM