Struct psl_core::Datasource
source · pub struct Datasource {Show 14 fields
pub name: String,
pub provider: String,
pub active_provider: &'static str,
pub url: StringFromEnvVar,
pub url_span: Span,
pub direct_url: Option<StringFromEnvVar>,
pub direct_url_span: Option<Span>,
pub documentation: Option<String>,
pub active_connector: &'static dyn Connector,
pub shadow_database_url: Option<(StringFromEnvVar, Span)>,
pub relation_mode: Option<RelationMode>,
pub namespaces: Vec<(String, Span)>,
pub schemas_span: Option<Span>,
pub connector_data: DatasourceConnectorData,
}
Expand description
a datasource
from the prisma schema.
Fields§
§name: String
§provider: String
The provider string
active_provider: &'static str
The provider that was selected as active from all specified providers
url: StringFromEnvVar
§url_span: Span
§direct_url: Option<StringFromEnvVar>
§direct_url_span: Option<Span>
§documentation: Option<String>
§active_connector: &'static dyn Connector
the connector of the active provider
shadow_database_url: Option<(StringFromEnvVar, Span)>
An optional user-defined shadow database URL.
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
Implementations§
source§impl Datasource
impl Datasource
sourcepub fn downcast_connector_data<T: 'static>(&self) -> Option<&T>
pub fn downcast_connector_data<T: 'static>(&self) -> Option<&T>
Extract connector-specific constructs. The type parameter must be the right one.
pub fn capabilities(&self) -> ConnectorCapabilities
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>where
F: Fn(&str) -> Option<String>,
pub fn load_url<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,
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>where
F: Fn(&str) -> Option<String>,
pub fn load_url_no_validation<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,
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>where
F: Fn(&str) -> Option<String>,
pub fn load_direct_url<F>(&self, env: F) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,
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>where
F: Fn(&str) -> Option<String>,
pub fn load_url_with_config_dir<F>( &self, config_dir: &Path, env: F ) -> Result<String, Diagnostics>where F: Fn(&str) -> Option<String>,
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.