Setting up the database
Before the Database example projects can run locally, a keyspace and a table need to be created in the local Cassandra database.
Start by opening the web interface. This can be done by clicking the OPEN WITH BROWSER icon of the web interface container in Docker Desktop.
At the top right corner in the web interface, there is an Execute button. This button opens a pop-up dialog where the cql-statements below can be pasted and executed.
Depending on if the java or nodejs project is being used, the cql is a bit different.
Java
Create the keyspace using the cql below:
```
CREATE KEYSPACE mingle_baas_databasejava
WITH REPLICATION = {
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
```
Then create the needed table using the following cql:
```
CREATE TABLE mingle_baas_databasejava.mytable (
basekey text,
key text,
value text,
PRIMARY KEY (basekey, key)
);
```
Add a record to the table using the following cql:
```
INSERT INTO mingle_baas_databasejava.mytable (basekey, key, value) VALUES ('basekey1','key1','value1');
```
NodeJS
Create the keyspace using the cql below:
```
CREATE KEYSPACE mingle_baas_databasenodejs
WITH REPLICATION = {
'class' : 'SimpleStrategy',
'replication_factor' : 1
};
```
Create the needed table using the following cql:
```
CREATE TABLE mingle_baas_databasenodejs.mytable (
basekey text,
key text,
value text,
PRIMARY KEY (basekey, key)
);
```
Add a record to the table using the following cql:
```
INSERT INTO mingle_baas_databasenodejs.mytable (basekey, key, value) VALUES ('basekey1','key1','value1');
```
The web interface can be used to verify that the keyspace and table have been successfully created.
Now the database is up and is running and ready for test.