-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate the SQL data model API to Cassandra (CQL) #34
Comments
Keyspace |
Important restrictions of Cassandra compared to SQL (adapted from StackOverflow while removing cases that are no longer valid):
The fourth and (to a lesser extent) fifth points seem to be the most severe. |
Cassandra offers a variant of a secondary index that might offer better performance / more functionality (e.g. the |
Current state of the issueAs of right now, the following points have been completed:
The point Where to store the new Regarding Copy
|
The following text is from Integrate Cassandra Support into Cenzontle
In order to implement the new storage type
cassandra
the following steps suggest themselves.Cassandra Setup / simple migration
First, setup a "sandbox" environment with Docker using the latest stable Cassandra Docker image and add it to our sandbox setup. Write a simple Cassandra Query Language script
setup_cassandra_db.js
to setup the Cassandra database for your needs, i.e. create aKEYSPACE default
and allTABLE
s required for your data models. Add an additional tableCREATE TABLE db_migrated ( migrated_at timeuuid PRIMARY KEY )
which will hold only a single row if and only if thesetup_cassandra_db.cql
has been executed, i.e. the last thing the script does is insert a row into the db_migrated table and thus mark the DB as ready for usage. The first thing thesetup_cassandra_db.js
script does is to check whether the database has been migrated already. If and only if the tabledb_migrated
does not exists and does not contain a valid row, the setup procedure will be executed. Extend the shell script used to start up the backend GraphQL-server to (i) wait for the Cassandra server to be available and (ii) run the migration-script.Information about how to obtain automatically generated
timeuuid
s can be found here.Indices and searches
Note that in the context of Cenzontle it is highly recommendable to create indices on all table columns in order to enable exhaustive searches.
Introduce the new storage type
cassandra
Copy
SQL
data model templatesMake two new storage types available:
cassandra
data models andcassandra-adapter
distributed data model (DDM) adapters. Copy the code-generator templates that are responsible for generating the data model layer modules forSQL
data models. Use the document in which theSQL
statements are defined that implement the respective data model layer functions and translate them toCQL
which is very alike toSQL
.Allow filtering to authorized users
Introduce a new authorization check in all read operations that execute database searches. Currently, only
read
will be checked on a given data model name or adapter name. Addsearch
to the checks. If the user hassearch
authorization appendALLOW FILTERING
to the generatedCQL
queries.Introduce a
cassandra
storage-handlerCurrently, Cenzontle's
models_index.js
script initializes the data models, including their connection to relational databases through Sequelize.Where to store the new
cassandra
models?Create a new directory
models-cassandra
in which Node.js modules for data models of the new storage typecassandra
will be stored.Initialize
cassandra
data models and adaptersProvide a JSON configuration file in
./config/cassandra.json
that has all data needed by the Node.js Cassandra Driver. Adjustmodels_index.js
to read in this config, initialize the Driver and set it in eachcassandra
data model module class as a constant propertystorageHandler
. See this post for how to define class constants in ECMA Script 6. Basically use something like the following snippetThe above has the advantage that both on the Person class level as well on the level of Person records (instances) the storage handler is available:
The text was updated successfully, but these errors were encountered: