CockroachDB is a distributed SQL database that offers several benefits over other databases:
CockroachDB comes with a generous free tier which can be used to build a Superblocks Application in minutes.
This post will look at an Internal Application allowing Support team members to search all active rides and track them in real time.
Superblocks provides native integration into CockroachDB, making it quick and easy to build Applications, Workflows and Scheduled Jobs that read and write to CockroachDB. By combining CockroachDB’s VPC peering alongside the Superblocks Agent, you’re able to keep all your customer data inside your own VPC. The Superblocks Agent is lightweight, and can be run as a docker container within your private network ensuring secure access to your data.
In a recent Webinar, Shy Ruparel and Aydrian Howard built out a ride-sharing application showing the live progress of rides from the CoackroachDB sample database and workload called MovR. With just a handful of components and a couple of APIs, users are able to filter a table to show all currently active journeys. When a journey is selected, a map component centers on the journey and tracks the journey’s progress live by using Timers.
With the CockroachDB integration setup an API can quickly be created to select data from the MovR database. The data is automatically returned from APIs as JSON making it easy to drop straight into a Table. Using Drag and Drop, a table component can be added to the canvas. To connect the dataset to the table, the API response can be selected in the Table Data property. A great time saving feature is that the table’s columns will automatically update to match the returned JSON data, no need to manually configure the columns!
Next is to connect this API to the Table’s onRowClicked event handler so that the API is run when a user selects a row. Event handlers are the binding glue between the frontend UI and the backend APIs. Each component comes with a variety of event handlers giving developers the freedom to build out complex Applications.
The Map can now be configured with both an initial location, to centralize the map, and Default markers to track the journey.
Using Timers we can easily make the map dynamic by calling the buildMap API at regular intervals so that journeys can be tracked on the Map in real time. Timers have a single Event Handler named onFire which allows any number of actions or APIs to be run at set intervals, this is all easily configurable within the UI. In this case, the Timer only needs to run the buildMap API and can do so every five seconds.
And that’s it! A usable Internal Application allowing Support team members to search all active rides and track them, all it took was CockroachDB, a handful of components and a couple of APIs!
As with all Superblocks Integrations their use isn't limited to building out Applications, they can also be used to build Workflows and Scheduled Jobs.
With Workflows, build reusable APIs that can be allied from Applications or other third-party services to surface data from CockroachDB
Scheduled Jobs are great for sending reports out by perhaps Slack or Email of business health.
Superblocks has helped hundreds of developers save 100s of hours of time both in building and in using internal applications.
In this blog we’ve focused on a particular example of how to use Superblocks with CockroachDB to build an application but keep in mind that Superblocks is also great for building Workflows and Scheduled Jobs. The workflows are valuable because the reusable APIs apllied from other apps or third-party surfaces can be used to surface data from CockroachDB. And the scheduled jobs are helpful for sharing business health reports via Slack or Email.
To learn more about how to create internal Applications, Jobs, and Workflows with Superblocks view our documentation. Try creating your first application today with a free 14-day trial.