Constructor

new

Metadata

(ClientOptions options, ControlConnection controlConnection)

Represents cluster and schema information. The metadata class acts as a internal state of the driver.

Parameters:
Name Type Description
options ClientOptions
controlConnection ControlConnection

Control connection used to retrieve information.

Methods

clearPrepared

()

Clears the internal state related to the prepared statements. Following calls to the Client using the prepare flag will re-prepare the statements.

getAggregate

(String keyspaceName, String name, Array<String> or Array<{code, info}> signature, [function callback])

Gets a definition of CQL aggregate for a given name and signature.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same aggregate definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace

name String

Name of the aggregate

signature Array<String> or Array<{code, info}>

Array of types of the parameters.

callback optional function

The callback with the err as a first parameter and the Aggregate as second parameter.

getAggregates

(String keyspaceName, String name, [function callback])

Gets the definition of CQL aggregate for a given name.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same aggregates definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace

name String

Name of the Function

callback optional function

The callback with the err as a first parameter and the array of Aggregate as second parameter.

getFunction

(String keyspaceName, String name, Array<String> or Array<{code, info}> signature, [function callback])

Gets a definition of CQL function for a given name and signature.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same function definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace

name String

Name of the Function

signature Array<String> or Array<{code, info}>

Array of types of the parameters.

callback optional function

The callback with the err as a first parameter and the SchemaFunction as second parameter.

getFunctions

(String keyspaceName, String name, [function callback])

Gets the definition of CQL functions for a given name.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same function definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace.

name String

Name of the Function.

callback optional function

The callback with the err as a first parameter and the array of SchemaFunction as second parameter.

getMaterializedView

(String keyspaceName, String name, [function callback])

Gets the definition of a CQL materialized view for a given name.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

Note that, unlike the rest of the Metadata methods, this method does not cache the result for following calls, as the current version of the Cassandra native protocol does not support schema change events for materialized views. Each call to this method will produce one or more queries to the cluster.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace

name String

Name of the materialized view

callback optional function

The callback with the err as a first parameter and the MaterializedView as second parameter.

getReplicas

(String keyspaceName, Buffer tokenBuffer)

Gets the host list representing the replicas that contain such partition.

It uses the pre-loaded keyspace metadata to retrieve the replicas for a token for a given keyspace. When the keyspace metadata has not been loaded, it returns null.

Parameters:
Name Type Description
keyspaceName String
tokenBuffer Buffer
Returns:
Type Description
Array

getTable

(String keyspaceName, String name, [function callback])

Gets the definition of a table.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same table definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace.

name String

Name of the Table.

callback optional function

The callback with the err as a first parameter and the TableMetadata as second parameter.

getTrace

(Uuid traceId, [Number consistency], [function callback])

Gets the trace session generated by Cassandra when query tracing is enabled for the query. The trace itself is stored in Cassandra in the sessions and events table in the system_traces keyspace and can be retrieve manually using the trace identifier.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

Parameters:
Name Type Description
traceId Uuid

Identifier of the trace session.

consistency optional Number

The consistency level to obtain the trace.

callback optional function

The callback with the err as first parameter and the query trace as second parameter.

getUdt

(String keyspaceName, String name, [function callback])

Gets the definition of an user-defined type.

If a callback is provided, the callback is invoked when the metadata retrieval completes. Otherwise, it returns a Promise.

When trying to retrieve the same UDT definition concurrently, it will query once and invoke all callbacks with the retrieved information.

Parameters:
Name Type Description
keyspaceName String

Name of the keyspace.

name String

Name of the UDT.

callback optional function

The callback to invoke when retrieval completes.

refreshKeyspace

(String name, [function callback])

Gets the keyspace metadata information and updates the internal state of the driver.

If a callback is provided, the callback is invoked when the keyspaces metadata refresh completes. Otherwise, it returns a Promise.

Parameters:
Name Type Description
name String

Name of the keyspace.

callback optional function

Optional callback.

refreshKeyspaces

([Boolean or function waitReconnect], [function callback])

Gets the metadata information of all the keyspaces and updates the internal state of the driver.

If a callback is provided, the callback is invoked when the keyspace metadata refresh completes. Otherwise, it returns a Promise.

Parameters:
Name Type Description
waitReconnect optional Boolean or function

Determines if it should wait for reconnection in case the control connection is not connected at the moment. Default: true.

callback optional function

Optional callback.