Skip to content

MaterializedViewBuilder ​

Parameters ​

NameDescription
viewNameName of the materialized view to create.
baseTableBase table from which to select data.

Example ​

typescript
const mv = new MaterializedViewBuilder("user_by_email", "users")
  .ifNotExists()
  .select("id", "email", "name")
  .where("email IS NOT NULL")
  .partitionKey("email")
  .clusteringKey("id")
  .clusteringOrder("id", "DESC")
const sql = mv.toSQL()
console.log(sql)

MaterializedViewBuilder ​

Fluent builder for creating ScyllaDB/Cassandra materialized views. Chain methods to configure view definition and generate the CREATE statement.

select ​

Specify columns to include in the view.

Parameters ​

NameDescription
columnsColumn names to select.

where ​

Add a WHERE clause condition.

Parameters ​

NameDescription
conditionRaw CQL condition string.

partitionKey ​

Define partition key columns (must include at least one).

Parameters ​

NameDescription
columnsColumn names for the partition key.

clusteringKey ​

Define clustering key columns.

Parameters ​

NameDescription
columnsColumn names for clustering.

clusteringOrder ​

Specify clustering order for a column.

Parameters ​

NameDescription
columnColumn name to order by.
direction'ASC' or 'DESC'.

ifNotExists ​

Add IF NOT EXISTS clause to avoid errors if view already exists.

toSQL ​

Compile and return the CREATE MATERIALIZED VIEW CQL statement.

Released under the MIT License.