Struct datamodel_renderer::configuration::Datasource
source · pub struct Datasource<'a> { /* private fields */ }
Expand description
The datasource block in a PSL file.
Implementations§
source§impl<'a> Datasource<'a>
impl<'a> Datasource<'a>
sourcepub fn new(name: &'a str, provider: &'a str, url: impl Into<Env<'a>>) -> Self
pub fn new(name: &'a str, provider: &'a str, url: impl Into<Env<'a>>) -> Self
Create a new datasource with all required properties.
ⓘ
datasource db {
// ^^ name
provider = "postgresql"
// ^^^^^^^^^^ provider
url = env("DATABASE_URL")
// ^^^^^^^^^^^^ url
}
sourcepub fn shadow_database_url(&mut self, url: impl Into<Env<'a>>)
pub fn shadow_database_url(&mut self, url: impl Into<Env<'a>>)
Used for schema engine to reflect the contents of migrations directory to diff against the actual database.
ⓘ
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
// ^^^^^^^^^^^^^^^^^^^ this
}
sourcepub fn relation_mode(&mut self, relation_mode: RelationMode)
pub fn relation_mode(&mut self, relation_mode: RelationMode)
Who handles referential integrity.
ⓘ
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
relationMode = "foreignKeys"
// ^^^^^^^^^^^ this
}
sourcepub fn push_custom_property(
&mut self,
key: &'a str,
value: impl Into<Value<'a>>
)
pub fn push_custom_property( &mut self, key: &'a str, value: impl Into<Value<'a>> )
Add a custom connector-specific property to the datasource.
Use this for settings that are only for a single database. For
shared things, add an explicit property to the Datasource
struct.
An example for PostgreSQL extensions, using an array of functions:
ⓘ
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
extensions = [citext(version: "2.1")]
// ^^^^^^^^^^^^^^^^^^^^^^^^ value
//^^^^^^^^^^ key
}
sourcepub fn documentation(&mut self, documentation: impl Into<Cow<'a, str>>)
pub fn documentation(&mut self, documentation: impl Into<Cow<'a, str>>)
The documentation on top of the datasource.
ⓘ
/// This here is the documentation.
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
sourcepub fn from_psl(
psl_ds: &'a Datasource,
force_namespaces: Option<&'a [String]>
) -> Self
pub fn from_psl( psl_ds: &'a Datasource, force_namespaces: Option<&'a [String]> ) -> Self
Create a rendering from a PSL datasource.
Trait Implementations§
source§impl<'a> Debug for Datasource<'a>
impl<'a> Debug for Datasource<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Datasource<'a>
impl<'a> Send for Datasource<'a>
impl<'a> Sync for Datasource<'a>
impl<'a> Unpin for Datasource<'a>
impl<'a> UnwindSafe for Datasource<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more