new Connection
The Cassandra Connection
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | The options for the connection defaults to: { port: 9160, host: 'localhost' user: null, password: null, keyspace: null, timeout: 1000 } |
- Source:
- connection.js, line 147
Members
-
_client
-
Thrift Client
- Source:
- connection.js, line 235
-
_connection
-
Thrift Connection
- Source:
- connection.js, line 218
-
cqlVersion
-
The CQL version. - Cassandra 1.0 supports CQL 2.0.0 - Cassandra 1.1 supports CQL 2.0.0 and 3.0.0 (with 2.0.0 the default) - Cassandra 1.2 will have CQL 3.0.0 as the default Cassandra will support choosing the CQL version for a while,
- Source:
- connection.js, line 197
- See:
-
- https://issues.apache.org/jira/browse/CASSANDRA-3990
-
host
-
The host to connect to
- Default Value:
- localhost
- Source:
- connection.js, line 164
-
keyspace
-
The keyspace to authenticate to
- Source:
- connection.js, line 185
-
password
-
The password to connect with
- Source:
- connection.js, line 180
-
port
-
The port to connect to
- Default Value:
- 9160
- Source:
- connection.js, line 158
-
ready
-
Ready state of the client
- Source:
- connection.js, line 202
-
timeout
-
The timeout for the connection
- Default Value:
- 3000
- Source:
- connection.js, line 170
-
user
-
The username to authenticate with
- Source:
- connection.js, line 175
-
<private, static, constant> DEFAULT_HOST
-
Default host
- Source:
- connection.js, line 32
-
<private, static, constant> DEFAULT_PORT
-
Default port for cassandra
- Source:
- connection.js, line 24
-
<private, static, constant> DEFAULT_TIMEOUT
-
Default Timeout
- Source:
- connection.js, line 40
-
<private, static, constant> NOOP
-
A No-Operation function for default callbacks
- Source:
- connection.js, line 16
Methods
-
authenticate
-
Authenticates the user
- Source:
- connection.js, line 337
-
close
-
Closes the connection to the server
- Source:
- connection.js, line 536
-
connect
-
Connects to the cassandra cluster
- Source:
- connection.js, line 209
-
cql
-
Executes a CQL Query Against the DB.
Parameters:
Name Type Description cmd
String A string representation of the query: 'select %s, %s from MyCf where key=%s' args0...argsN
Array An Array of arguments for the string ['arg0', 'arg1', 'arg2'] options
Object An object with options for the query, { gzip:true } callback
Function The callback function for the results - Source:
- connection.js, line 396
-
createKeyspace
-
Creates a keyspace
Parameters:
Name Type Description keyspace
String The name of the keyspace to create options
Object Keyspace options callback
Function The callback to invoke once complete - Source:
- connection.js, line 469
-
dropKeyspace
-
Drops a keyspace
Parameters:
Name Type Description name
String The keyspace name - Source:
- connection.js, line 515
-
execute
-
Executes a command via the thrift connection
Parameters:
Name Type Description command
String The command to execute additional params are supplied to the command to be executed - Source:
- connection.js, line 362
-
use
-
Sets the current keyspace
Parameters:
Name Type Description keyspace
String The keyspace to use - Source:
- connection.js, line 312
-
<private, static> createError
-
Creates a JS Error from a Cassndra Error
Parameters:
Name Type Description err
Object The cassandra error eg: { name:'Exception', why:'Some Reason' } - Source:
- connection.js, line 48
-
<private, static> escapeCQL
-
Escapes CQL, adapted from node-mysql
Parameters:
Name Type Description val
String The value to be escaped - Source:
- connection.js, line 95
Returns:
The sanitized string- Type
- String
-
<private, static> formatCQL
-
Formats CQL properly, paradigm borrowed from node-mysql: https://github.com/felixge/node-mysql/blob/master/lib/client.js#L145-199
Parameters:
Name Type Description str
String - Source:
- connection.js, line 65
Returns:
The formatted CQL statement- Type
- String