-
Notifications
You must be signed in to change notification settings - Fork 0
Adding a new Cassandra table
Milan Gruner edited this page Jul 25, 2017
·
4 revisions
To load the contents of a new Cassandra table into the Curation API, follow these steps:
- If the keyspace isn't loaded into Curation yet, add a config in
src/api/keyspaceConfigs
- Add a new query config containing the fields as lists by field type to
src/api/queryConfigs
(can be reused if the new table has the same structure as a previous table) - Add a new model file containing the fields, primary key and table name to
src/api/models
- Add the model's name, source path and table name to the schema config of the corresponding keyspace in
src/api/schemaConfigs/<KEYSPACE_NAME>Config.js
- Import the new query config (if any) at the top of
src/server.js
(also import new keyspace and keyspace schema configs if created) - Choose an API route, add it to a new
app.use
call at the bottom ofsrc/server.js
, containing amodelRouter
call with the correct keyspace models, model name and query config, e.g.: app.use('/api/subjects', modelRouter(datalakeModels, 'Subject', subjectsQueryConfig));
As a reference for the file structure refer to the other files in the corresponding directories.
To query the newly created API endpoint in the Curation frontend, do the following:
- Add a new duck to
src/ducks
, which contains the actions querying the chosen API route and the reducers that store this data - Add this duck's reducer to
src/ducks/reducers.js
(also import it at the top) - Connect to the corresponding Redux store at the bottom of a React component by using the
connect()
andbindActionCreators()
calls fromreact-redux
- Use the data from
this.props
inside the component (maybe check for changes insidecomponentWillReceiveProps()
if necessary)