How do I use cube.js to define my own schemas

838 Views Asked by At

I want to build schema file from my frontend app just like what happens in cube.js playground in dev mode. Is there any possibility to do so?

1

There are 1 best solutions below

0
On

Cube.js is meant to be used as a backend analytics API layer, that's why you should run it separately from your front-end project.

The general workflow is:

  1. Setup cubejs backend project, and connect it to your data source.
  2. Create js files in your cubejs project in the schema folder and define cubes that fit your use case. Follow the guide at cube.dev on how to create cubes
├── package-lock.json
├── package.json
└── schema
    ├── file_with_cubes.js
    ├── file_with_cubes2.js
    ├── file_with_cubes3.js
  1. Setup front-end project with cubeJsClient library to be able to talk to cubejs backend. check front-end integration docs
  2. Use your query format of choice with cubeJsClient on the front end, to query cubejs backend and get results.
  3. You will get the result from API call, [manipulate it] then visualize it.