class Client
Extends the
Client class of the
DataStax Node.js Driver for Apache Cassandra
to provide DSE-specific features support such as Graph, geospatial types representation and authentication, in
addition to the inherited Client methods used to execute CQL queries (execute(),
eachRow(), stream()).
Client instances are designed to be long-lived and usually a single instance is enough per application.
- Global
- This class is global
Augments
cassandra.Client
Events
hostAdd
Emitted when a new host is added to the cluster.
-
HostThe host being added.
hostDown
Emitted when a host in the cluster changed status from up to down.
-
hostThe host that changed the status.
hostRemove
Emitted when a host is removed from the cluster
-
HostThe host being removed.
hostUp
Emitted when a host in the cluster changed status from down to up.
-
hostThe host that changed the status.
Members
HostMap hosts
Gets an associative array of cluster hosts.
String keyspace
Gets the name of the active keyspace.
Metadata metadata
Gets the schema and cluster metadata information.
ClientMetrics metrics
The ClientMetrics instance used to expose measurements of its internal
behavior and of the server as seen from the driver side.
By default, a DefaultMetrics instance is used.
Constructor
Client
(DseClientOptions options)
Creates a new Client instance.
Methods
batch
(Array<string> or Array<{query, params}> queries, [QueryOptions options], [ResultCallback callback])
Executes batch of queries on an available connection to a host.
If a callback is provided, it will invoke the callback when the execution completes. Otherwise,
it will return a Promise.
connect
([function callback])
Tries to connect to one of the contactPoints and discovers the rest the nodes of the cluster.
If a callback is provided, it will invoke the callback when the client is connected. Otherwise,
it will return a Promise.
If the Client is already connected, it invokes callback immediately (when provided) or the promise is
fulfilled .
eachRow
(String query, [Array or Object params], [QueryOptions options], function rowCallback, [function callback])
Executes the query and calls rowCallback for each row as soon as they are received. Calls final callback after all rows have been sent, or when there is an error.
The query can be prepared (recommended) or not depending on QueryOptions.prepare flag. Retries on multiple
hosts if needed.
Executes a query on an available connection.
If a callback is provided, it will invoke the callback when the execution completes. Otherwise,
it will return a Promise.
The query can be prepared (recommended) or not depending on QueryOptions.prepare flag.
Some executions failures can be handled transparently by the driver, according to the
RetryPolicy defined at ClientOptions or QueryOptions
level.
executeGraph
(String query, [Object or null parameters], [GraphQueryOptions or null options], [function callback])
Executes a graph query.
If a callback is provided, it will invoke the callback when the execution completes. Otherwise,
it will return a Promise.
Gets the host list representing the replicas that contain such partition.
getState
()Gets a snapshot containing information on the connections pools held by this Client at the current time.
The information provided in the returned object only represents the state at the moment this method was called and it’s not maintained in sync with the driver metadata.
shutdown
([function callback])
Closes all connections to all hosts.
If a callback is provided, it will invoke the callback when the client is disconnected. Otherwise,
it will return a Promise.
Executes the query and pushes the rows to the result stream as soon as they received. Calls callback after all rows have been sent, or when there is an error.
The stream is a Readable Streams2 object
that contains the raw bytes of the field value.
It can be piped downstream and provides automatic pause/resume logic (it buffers when not read).
The query can be prepared (recommended) or not depending on QueryOptions.prepare flag. Retries on multiple
hosts if needed.