Sequelize
Sequelize is a modern TypeScript and Node.js ORM for Postgres, MySQL, MariaDB, SQLite and SQL Server, and more. It features solid transaction support, relations, eager and lazy loading, read replication and more.
Connecting to bit.io with Sequelize
In order to connect Sequelize with bit.io, you'll need to find your PostgreSQL connection credentials from the bit.io Connect Tab of the database to which you would like to connect. You can find everything you need to know about your PostgreSQL credentials here
Follow the installation instructions found here. Make sure to install the dependencies for PostgreSQL.
Then use your bit.io connection string as in the following code sample:
const { Sequelize } = require("sequelize");
const sequelize = new Sequelize('[your-connection-string]?sslmode=require')
const main = async () => {
try {
await sequelize.authenticate();
console.log("Connection has been established successfully.");
} catch (error) {
console.error("Unable to connect to the database:", error);
}
};
main();
Add SSL Param
Please note the addition of the
?sslmode=require
parameter to the connection string. Without this authentication will fail
Using Sequelize with bit.io
From here you're ready to begin using your bit.io database inside your node app!
Updated 11 months ago