Constructor
new Metadata(options, controlConnection)
Creates a new instance of Metadata.
Parameters:
Name | Type | Description |
---|---|---|
options |
ClientOptions | |
controlConnection |
ControlConnection | Control connection used to retrieve information. |
- Source:
Methods
checkSchemaAgreement(callbackopt) → {Promise}
Checks whether hosts that are currently up agree on the schema definition.
This method performs a one-time check only, without any form of retry; therefore
protocolOptions.maxSchemaAgreementWaitSeconds
setting does not apply in this case.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
callback |
function |
<optional> |
A function that is invoked with a value
|
- Source:
Returns:
Returns a Promise
when a callback is not provided. The promise resolves to
true
when all hosts agree on the schema and false
when there is no agreement or when
the check could not be performed (for example, if the control connection is down).
- Type
- Promise
clearPrepared()
Clears the internal state related to the prepared statements. Following calls to the Client using the prepare flag will re-prepare the statements.
- Source:
getAggregate(keyspaceName, name, signature, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace |
|
name |
String | Name of the aggregate |
|
signature |
Array.<String> | Array.<{code, info}> | Array of types of the parameters. |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the Aggregate as second parameter. |
- Source:
getAggregates(keyspaceName, name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace |
|
name |
String | Name of the Function |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the array of Aggregate as second parameter. |
- Source:
getFunction(keyspaceName, name, signature, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace |
|
name |
String | Name of the Function |
|
signature |
Array.<String> | Array.<{code, info}> | Array of types of the parameters. |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the SchemaFunction as second parameter. |
- Source:
getFunctions(keyspaceName, name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace. |
|
name |
String | Name of the Function. |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the array of SchemaFunction as second parameter. |
- Source:
getMaterializedView(keyspaceName, name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace |
|
name |
String | Name of the materialized view |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the MaterializedView as second parameter. |
- Source:
getReplicas(keyspaceName, token) → {Array}
Gets the host list representing the replicas that contain the given partition key, token or token range.
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 | |
token |
Buffer | Token | TokenRange | Can be Buffer (serialized partition key), Token or TokenRange |
- Source:
Returns:
- Type
- Array
getTable(keyspaceName, name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace. |
|
name |
String | Name of the Table. |
|
callback |
function |
<optional> |
The callback with the err as a first parameter and the TableMetadata as second parameter. |
- Source:
getTokenRanges() → {Set.<TokenRange>}
Gets the token ranges that define data distribution in the ring.
- Source:
Returns:
The ranges of the ring or empty set if schema metadata is not enabled.
- Type
- Set.<TokenRange>
getTokenRangesForHost(keyspaceName, host) → {Set.<TokenRange>|null}
Gets the token ranges that are replicated on the given host, for the given keyspace.
Parameters:
Name | Type | Description |
---|---|---|
keyspaceName |
String | The name of the keyspace to get ranges for. |
host |
Host | The host. |
- Source:
Returns:
Ranges for the keyspace on this host or null if keyspace isn't found or hasn't been loaded.
- Type
- Set.<TokenRange> | null
getTrace(traceId, consistencyopt, callbackopt)
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 | Attributes | Description |
---|---|---|---|
traceId |
Uuid | Identifier of the trace session. |
|
consistency |
Number |
<optional> |
The consistency level to obtain the trace. |
callback |
function |
<optional> |
The callback with the err as first parameter and the query trace as second parameter. |
- Source:
getUdt(keyspaceName, name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
keyspaceName |
String | Name of the keyspace. |
|
name |
String | Name of the UDT. |
|
callback |
function |
<optional> |
The callback to invoke when retrieval completes. |
- Source:
isDbaas() → {boolean}
Determines whether the cluster is provided as a service.
- Source:
Returns:
true when the cluster is provided as a service (DataStax Astra), false
when it's a
different deployment (on-prem).
- Type
- boolean
newToken(components) → {Token}
Constructs a Token from the input buffer(s) or string input. If a string is passed in it is assumed this matches the token representation reported by cassandra.
Parameters:
Name | Type | Description |
---|---|---|
components |
Array.<Buffer> | Buffer | String |
- Source:
Returns:
constructed token from the input buffer.
- Type
- Token
newTokenRange(start, end)
Constructs a TokenRange from the given start and end tokens.
Parameters:
Name | Type | Description |
---|---|---|
start |
Token | |
end |
Token |
- Source:
Returns:
TokenRange build range spanning from start (exclusive) to end (inclusive).
refreshKeyspace(name, callbackopt)
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 | Attributes | Description |
---|---|---|---|
name |
String | Name of the keyspace. |
|
callback |
function |
<optional> |
Optional callback. |
- Source:
refreshKeyspaces(waitReconnectopt, callbackopt)
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 | Attributes | Description |
---|---|---|---|
waitReconnect |
Boolean | function |
<optional> |
Determines if it should wait for reconnection in case the control connection is not connected at the moment. Default: true. |
callback |
function |
<optional> |
Optional callback. |
- Source: