docs/ts/develop/orms/overview.md
Encore provides built-in support for ORMs and migration frameworks by offering named databases and SQL-based migration files. For developers who prefer not to write raw SQL, Encore allows seamless integration with popular ORMs and migration tools.
Encore’s approach to database management is flexible. It uses standard SQL migration files, allowing integration with ORMs like Sequelize and migration tools like Atlas.
Encore provides the SQLDatabase class, which allows you to create a named database and retrieve its connection string. This connection string can be used by your chosen ORM or migration framework to establish a database connection.
Example setup:
import { SQLDatabase } from "encore.dev/storage/sqldb";
// Initialize a named database with migration directory
const SiteDB = new SQLDatabase("siteDB", {
migrations: "./migrations",
});
// Retrieve the connection string for ORM use
const connStr = SiteDB.connectionString;
Here are some guides to using different ORMs with Encore:
This setup enables Encore to support a wide variety of ORMs and migration frameworks, making database management both flexible and straightforward.