SingleStore DB

Connect with Node.js

Whether you're using an ORM or straight SQL, you can get started with SingleStore (formerly MemSQL) and Node quickly. SingleStore is wire-compliant with MySQL, meaning connecting to SingleStore is as easy as connecting to a MySQL database.

The sections below describe how to connect your application. For a complete example, including samples of CRUD operations, refer to the following video and associated GitHub repo.

Prerequisites
  • Install (or update to) a supported version Node (v14 or newer).

  • Install the mysql2 npm module: npm install --save mysql2

Connection Details

To connect your Node.js application to your SingleStore cluster (SingleStore DB or SingleStore Managed Service) you'll need the following:

  • Host: the Admin endpoint (SingleStore Managed Service) or IP Address (SingleStore DB) for your cluster. You can find the Admin endpoint in the SingleStore Portal.

  • Port: default is 3306

  • User: admin (SingleStore Managed Service) or root (SingleStore DB).

  • Password

Here is an example of a Node connection for a SingleStore Managed Service cluster:

const db = mysql.createConnection({
    host: 'svc-1234ebc1-ab6f-123d-8e67-cd5d066ca0e8-ddl.aws-region-1.svc.singlestore.com',
    user: 'admin',
    password: <Admin Password>
    database: <Database Name>
    });
More Information

Using Stored Procedures: GitHub

Using ORM: GitHub