pub struct Datasource {Show 15 fields
pub name: String,
pub span: Span,
pub provider: String,
pub active_provider: &'static str,
pub documentation: Option<String>,
pub active_connector: &'static dyn Connector,
pub relation_mode: Option<RelationMode>,
pub namespaces: Vec<(String, Span)>,
pub schemas_span: Option<Span>,
pub connector_data: DatasourceConnectorData,
pub url: StringFromEnvVar,
pub url_span: Span,
pub direct_url: Option<StringFromEnvVar>,
pub direct_url_span: Option<Span>,
pub shadow_database_url: Option<(StringFromEnvVar, Span)>,
}Expand description
a datasource from the prisma schema.
Fields§
§name: String§span: SpanSpan of the whole datasource block (including datasource keyword and braces)
provider: StringThe provider string
active_provider: &'static strThe provider that was selected as active from all specified providers
documentation: Option<String>§active_connector: &'static dyn Connectorthe connector of the active provider
relation_mode: Option<RelationMode>In which layer referential actions are handled.
namespaces: Vec<(String, Span)>Sorted vec of schemas defined in the schemas property.
schemas_span: Option<Span>§connector_data: DatasourceConnectorData§url: StringFromEnvVarURL-related fields will no longer be parsed from Prisma Schemas in Prisma 7.0.0.
url_span: Span§direct_url: Option<StringFromEnvVar>§direct_url_span: Option<Span>§shadow_database_url: Option<(StringFromEnvVar, Span)>An optional user-defined shadow database URL.
Implementations§
Source§impl Datasource
impl Datasource
pub fn override_urls(&mut self, datasource_urls_override: DatasourceUrls)
Sourcepub fn downcast_connector_data<T>(&self) -> Option<&T>where
T: 'static,
pub fn downcast_connector_data<T>(&self) -> Option<&T>where
T: 'static,
Extract connector-specific constructs. The type parameter must be the right one.
pub fn capabilities(&self) -> BitFlags<ConnectorCapability>
Sourcepub fn relation_mode(&self) -> RelationMode
pub fn relation_mode(&self) -> RelationMode
The applicable relation mode for this datasource.
Sourcepub fn load_url<F>(&self, env: F) -> Result<String, Diagnostics>
pub fn load_url<F>(&self, env: F) -> Result<String, Diagnostics>
Load the database URL, validating it and resolving env vars in the
process. Also see load_url_with_config_dir().
Sourcepub fn load_url_no_validation<F>(&self, env: F) -> Result<String, Diagnostics>
pub fn load_url_no_validation<F>(&self, env: F) -> Result<String, Diagnostics>
Load the database URL, without validating it and resolve env vars in the process.
Sourcepub fn load_direct_url<F>(&self, env: F) -> Result<String, Diagnostics>
pub fn load_direct_url<F>(&self, env: F) -> Result<String, Diagnostics>
Load the direct database URL, validating it and resolving env vars in the
process. If there is no directUrl passed, it will default to load_url().
Sourcepub fn load_url_with_config_dir<F>(
&self,
config_dir: &Path,
env: F,
) -> Result<String, Diagnostics>
pub fn load_url_with_config_dir<F>( &self, config_dir: &Path, env: F, ) -> Result<String, Diagnostics>
Same as load_url(), with the following difference.
By default we treat relative paths (in the connection string and datasource url value) as relative to the CWD. This does not work in all cases, so we need a way to prefix these relative paths with a config_dir.
This is, at the time of this writing (2021-05-05), only used in the context of Node-API integration.
P.S. Don’t forget to add new parameters here if needed!
Sourcepub fn load_shadow_database_url(&self) -> Result<Option<String>, Diagnostics>
pub fn load_shadow_database_url(&self) -> Result<Option<String>, Diagnostics>
Load the shadow database URL, validating it and resolving env vars in the process.
pub fn provider_defined(&self) -> bool
pub fn url_defined(&self) -> bool
pub fn direct_url_defined(&self) -> bool
pub fn shadow_url_defined(&self) -> bool
pub fn relation_mode_defined(&self) -> bool
pub fn schemas_defined(&self) -> bool
Trait Implementations§
Source§impl Clone for Datasource
impl Clone for Datasource
Source§fn clone(&self) -> Datasource
fn clone(&self) -> Datasource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Datasource
impl Debug for Datasource
Auto Trait Implementations§
impl Freeze for Datasource
impl !RefUnwindSafe for Datasource
impl Send for Datasource
impl Sync for Datasource
impl Unpin for Datasource
impl UnsafeUnpin for Datasource
impl !UnwindSafe for Datasource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more