April 2nd 2017

Introducing Store Adapters for external database connectivity

Since the inception of the Eventn platform, we have always believed that easily being able to persist and query data was an essential feature of data-driven microservice platform. To support that requirement, Eventn launched with an embedded database table that is automatically generated and securely connected to each microservice.

Today we are pleased to announce the introduction of the Store Adapter interface for rapid connectivity to external databases. This new functionality makes it fast and simple to connect to an external database from an Eventn microservice, supporting MySQL, PostgreSQL, MariaDB and Microsoft SQL Server.

Getting Connected

A store adapter is a JavaScript function that holds all of the connection credentials and can be called from any Eventn microservice. The platform takes care of loading and validating the connection and multiple connectors can be used from a single microservice making transformation and migration use cases simple.

To create a store adapter function, simple send POST request to the /store resource and pass in the details of the database connection. For example, to connect to a MySQL database, the following example could be used:

  "adapter_type": "mysql",
  "name": "warehouse",
  "default_table": "sales",
  "connection_string": "mysql://db_user:password@0myhost:3306/demo"

The important property here is thenameas this is how the connection will be referenced from within a microservice.


Each store adapter function returns a Knex instance which provides a powerful SQL query builder. Calling an external database is then a breeze from within any microservice (note the function name is as defined when creating the store adapter - in this casewarehouse:

return context.stores.warehouse("sales").count();
Or with a raw sql query:
return context.stores.warehouse().raw('select count(*) from sales');

Further Reading

Read more about Store Adapters in the User Guide or see the API Reference for details on creating a store adapter.