Reputation: 1407
I use node.js version 6.9.2 and Cassandra 3.9.
I would like to set a consistency level of LOCAL_QUORUM for all my queries when creating the Client instance.
According to this documentation, I need to do like the following.
const client = new Client({ queryOptions: { consistency: types.consistencies.quorum } });
I changed the consistency level of quorum to local_quorum.
const client = new Client({ queryOptions: { consistency: types.consistencies.local_quorum } });
However, when I start my app with this snippet of code, I receive an error.
ReferenceError: types is not defined
So, without fully understanding this meaning, I set text in place of types.
const client = new Client({ queryOptions: { consistency: text.consistencies.local_quorum } });
I received another error.
ReferenceError: text is not defined
My questions are:
What should be the value of types
?
Is changing the quorum
to local_quorum
necessary to have the consistency level of LOCAL_QUORUM? If it isn't, what is the correct way to assign LOCAL_QUORUM to my queries?
Upvotes: 2
Views: 2287
Reputation: 407
The type consistency is suppose to be types.consistencies.localQuorum
if i remember correctly :)
Adding more info: The types is Inside the driver requirement to access it you need to declare it before
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({ contactPoints: ['host1'] });
client.connect(function (err) {
assert.ifError(err);
client.execute(query, params, { consistency: cassandra.types.consistencies.localQuorum }, function (err) {
//This callback will be called once it has been written in the number of replicas
//satisfying the consistency level specified.
});
});
Upvotes: 5