Skip to main content
Version: 3.0 Alpha

Data Source

The datasource block provides information about the database your application uses. The ORM relies on it to determine the proper SQL dialect to use when generating queries. If you use Migration, it must also have a url field that specifies the database connection string, so that the migration engine knows how to connect to the database. The env function can be used to reference environment variables so you can keep sensitive information out of the code.

tip

You can use both single quote and double quote for string literals.

Each ZModel schema must have exactly one datasource block.

datasource db {
provider = 'postgresql'
url = env('DATABASE_URL')
}

Currently only PostgreSQL and SQLite are supported. MySql will be supported in a future release. There's no plan for other relational database types or NoSQL databases.

🔋 ZModel vs Prisma Schema

ZenStack's ORM runtime doesn't rely on the url information to connect to the database. Instead, you provide the information when constructing an ORM client. More on this in the ORM section.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below