Data modeling
Testing your models

Using the Data Playground

You can test your models in Embeddable’s Data Playground, available both in your online workspace and locally by running:

npm run embeddable:dev
  • Simply click the Data Playground tab in the left sidebar.
  • You’ll then be able to test each element of your models, view the generated SQL, and inspect the results.

Testing using Cube's Data Playground

You can also use Cube's local Data Playground to test and debug your models.

This relies on you having Docker (opens in a new tab) installed on your local machine.

Create a .env file:

Ensure your .env file is in the same directory as cube-playground.yml (this directory (opens in a new tab)).

Populate the .env file:

Populate the .env file with the correct database credentials for your database as per the Cube's documentation (opens in a new tab).

CUBEJS_DB_TYPE=postgres
CUBEJS_DB_HOST=localhost
CUBEJS_DB_NAME=your_database
CUBEJS_DB_USER=your_username
CUBEJS_DB_PASS=your_password

You may need to add:

CUBEJS_DB_SSL=true

You can also add set the desired level of logging detail, which can be useful for debugging and monitoring:

CUBEJS_DB_SSL=warn 

Possible values:
warn (default value): Logs warnings in addition to errors.
Example: Deprecation warnings or configuration issues.

error: Logs only critical errors that affect the application's functionality.
Example: Database connection issues or critical service failures.

info: Logs general informational messages about the application's operations.
Example: Application startup, health checks, or key lifecycle events.

trace: Logs the most detailed information, primarily used for in-depth debugging.
Example: Internal function calls and exhaustive execution details.

Run the Playground

Execute the following command to start Cube's data playground:

npm run cube:playground

You can also use docker compose:

docker compose -f ./src/cube-playground.yml up

Access the Playground

Open your browser and navigate to localhost:4000 (opens in a new tab) to use Cube Playground.

Still Need Help?

If you encounter any issues while testing your data models, feel free to reach out to our Slack community (opens in a new tab) or contact our support team for assistance.