Was this page helpful?
Caution
You're viewing documentation for an unstable version of ScyllaDB Node.js Driver. Switch to the latest stable version.
Metadata¶
metadata~Metadata(options, controlConnection)
Represents cluster and schema information. The metadata class acts as a internal state of the driver.
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. |
Methods¶
checkSchemaAgreement() → {Boolean}
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.
Returns:
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
- Boolean
getAggregate(keyspaceName, name, signature) → {Aggregate|null}
Gets a definition of CQL aggregate for a given name and signature.
Parameters:
| Name | Type | 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. |
Returns:
The schema aggregate metadata, or null if it does not exist.
- Type
- Aggregate | null
getAggregates(keyspaceName, name) → {Array<Aggregate>}
Gets the definition of CQL aggregate for a given name.
Parameters:
| Name | Type | Description |
|---|---|---|
keyspaceName |
string | Name of the keyspace. |
name |
string | Name of the aggregate. |
Returns:
An array of schema aggregate metadata.
- Type
- Array<Aggregate>
getFunction(keyspaceName, name, signature) → {SchemaFunction|null}
Gets a definition of CQL function for a given name and signature.
Parameters:
| Name | Type | 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. |
Returns:
The schema function metadata, or null if it does not exist.
- Type
- SchemaFunction | null
getFunctions(keyspaceName, name) → {Array<SchemaFunction>}
Gets the definition of CQL functions for a given name.
Parameters:
| Name | Type | Description |
|---|---|---|
keyspaceName |
string | Name of the keyspace. |
name |
string | Name of the Function. |
Returns:
An array of schema function metadata.
- Type
- Array<SchemaFunction>
getKeyspace(name) → {KeyspaceMetadata|null}
Gets the keyspace metadata by name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the keyspace. |
Returns:
The keyspace metadata, or null if it does not exist.
- Type
- KeyspaceMetadata | null
getKeyspaces() → {Map<string, KeyspaceMetadata>}
Gets all keyspace metadata.
Returns:
A map of all keyspaces indexed by name.
- Type
- Map<string, KeyspaceMetadata>
getMaterializedView(keyspaceName, name) → {MaterializedView|null}
Gets the definition of a CQL materialized view for a given name.
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 |
Returns:
The materialized view definition, or null if it does not exist.
- Type
- MaterializedView | null
getReplicas(keyspaceName, token) → {Array<Host>}
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 | Name of the keyspace. |
token |
Buffer | Token | TokenRange | Can be Buffer (serialized partition key), Token or TokenRange. |
Returns:
.
- Type
- Array<Host>
getTable(keyspaceName, name) → {TableMetadata|null}
Gets the definition of a table.
Parameters:
| Name | Type | Description |
|---|---|---|
keyspaceName |
string | Name of the keyspace. |
name |
string | Name of the Table. |
Returns:
The table metadata, or null if it does not exist.
- Type
- TableMetadata | null
getTokenRanges() → {Set<TokenRange>}
Gets the token ranges that define data distribution in the ring.
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. |
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)
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.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
traceId |
Uuid | Identifier of the trace session. |
|
consistency |
Number |
<optional> |
The consistency level to obtain the trace. |
getUdt(keyspaceName, name) → {Udt|null}
Gets the definition of an user-defined type.
Parameters:
| Name | Type | Description |
|---|---|---|
keyspaceName |
string | Name of the keyspace. |
name |
string | Name of the UDT. |
Returns:
The UDT definition, or null if it does not exist.
- Type
- Udt | null
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 | The token components. |
Returns:
constructed token from the input buffer.
- Type
- Token
newTokenRange(start, end) → {TokenRange}
Constructs a TokenRange from the given start and end tokens.
Parameters:
| Name | Type | Description |
|---|---|---|
start |
Token | The start token. |
end |
Token | The end token. |
Returns:
build range spanning from start (exclusive) to end (inclusive).
- Type
- TokenRange