On MariaDB Connector/Node.js. Q&A with Thomas Boyd

Q1. Some in the Node.js development community might have been surprised by the announcement of the release of MariaDB Connector/Node.js. People have been connecting Node.js to MariaDB for years –why is this an important announcement for the MariaDB community?

On a purely technical level, the MariaDB Connector/Node.js is providing features and performance that is not available from other drivers. A 70% gain on single queries, and the ability to use pipelining and streaming for more dramatic gains are big wins for application developers. But it is really bigger than just the performance story. As Node.js has moved into enterprise IT, expectations for support have changed. Language drivers are a critical part of the stack, and having MariaDB directly support and maintain a language driver means that IT Directors and Architects can take advantage of all the benefits of building on Node.js knowing that MariaDB will be there to help if issues arise.

Q2.There is a set of language connectors that MariaDB directly builds, maintains and releases for your Enterprise version. How do you select language connectors you support directly?

MariaDB maintains a close relationship with our customers and users. Whether it is through our consulting, support, sales, or events like our roadshows and annual user conferences, we get a lot of feedback and insight into how our customer are using MariaDB. It isn’t hard to see when a language or technology is becoming mainstream. While the sheer number of languages means that there will always be drivers that remain community maintained, we need to extend our support into the most widely adopted languages.

Q3. The 2018 Node.js User Survey reported that Web Apps remain the most popular use case for Node, with 85% of respondents indicating they use Node for this work. 43% of respondents indicate they use Node for enterprise applications. Why is Node.js important to your customers and users?

Regardless of the specific application focus, Node.js has brought new levels of productivity and performance to programmers. Having javascript as a common language across the front-end and application tiers makes full-stack developers more efficient. It also means that there is a bigger pool of programmers than for many other languages. On the performance side, the asynchronous model in Node.js greatly improves throughput for many applications. Who doesn’t like a lower bill from your cloud provider!

Q4. Can you tell us in a nutshell how to build Node.js apps with the MariaDB connector?

Well, it would have to be a pretty big nutshell, but let me try! A lot depends on whether you are using higher-level frameworks to support your app. If you aren’t using frameworks, you are going to start by downloading the MariaDB Connector/Node.js using the npm package manager. You will then include the connector in your application file(s), create a connection to a MariaDB instance, and then use that connection to send SQL statements to the MariaDB instance. Those statements can include any valid SQL — queries, inserts, updates, deletes, and data definition statements (e.g. table creation). These basic interactions with the database are usually wrapped into higher level services that provide the building blocks for your application logic and user interactions. If you’d like a deeper dive, I’d encourage you to check out the session “Building Better Node.js on MariaDB” at our upcoming MariaDB OpenWorks conference in NYC.

Q5. How does it work to use the MariaDB connector with Node.js ORM frameworks?

If you are building on top of an ORM like Sequelize or a frameworks like FeathersJS and Express, very little actually changes. You simply choose “mariadb” as the storage dialect and ensure that you have a MariaDB instance up and running. The other steps of declaring models and services, etc… all remain unchanged. Of course, if you find that the ORM or framework is too restrictive, you can always write some portion of your database logic with direct SQL calls via the MariaDB Connector/Node.js.

Q6. How do you take advantage of SQL with JSON functions, and temporal tables?

MariaDB JSON functionality and temporal queries are great examples of where you can use the full power of SQL by writing your own queries with the MariaDB Connector/Node.js. Let’s take capturing and querying temporal data as an example. Suppose you have an application that is updating the price of an item in your webstore and you decide that you need to capture the history of those price changes. Rather than rewriting your application (and completely bypassing your helpful ORM) you could simply enable system versioning on your product table and this history is automatically captured. Those services that needed to expose this historical information would then write their own SQL.


Thomas Boyd, Director of Technical Marketing, MariaDB Corporation

Thomas joined MariaDB in 2017. He brings with him 25 years of experience in the IT industry, with a focus on databases and data storage technologies. Prior to MariaDB, Thomas worked at Oracle, Hewlett-Packard, MongoDB, and was a founder at OuterBay Technologies (later acquired by Hewlett-Packard). Thomas lives in San Francisco Bay Area with his wife and two boys.

You may also like...