Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.51 KB

File metadata and controls

46 lines (35 loc) · 1.51 KB
sidebar_position 2
description Datasource in ZModel

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import ZModelVsPSL from '../_components/ZModelVsPSL';

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.

```zmodel datasource db { provider = 'postgresql' url = env('DATABASE_URL') } ``` ```zmodel datasource db { provider = 'sqlite' url = 'file:./dev.db' } ```

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.

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](../orm/) section.