Skip to main content

Datasource

Struct Datasource 

Source
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: Span

Span of the whole datasource block (including datasource keyword and braces)

§provider: String

The provider string

§active_provider: &'static str

The provider that was selected as active from all specified providers

§documentation: Option<String>§active_connector: &'static dyn Connector

the 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: StringFromEnvVar

URL-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

Source

pub fn override_urls(&mut self, datasource_urls_override: DatasourceUrls)

Source

pub fn downcast_connector_data<T>(&self) -> Option<&T>
where T: 'static,

Extract connector-specific constructs. The type parameter must be the right one.

Source

pub fn capabilities(&self) -> BitFlags<ConnectorCapability>

Source

pub fn relation_mode(&self) -> RelationMode

The applicable relation mode for this datasource.

Source

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().

Source

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.

Source

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().

Source

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!

Source

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.

Source

pub fn provider_defined(&self) -> bool

Source

pub fn url_defined(&self) -> bool

Source

pub fn direct_url_defined(&self) -> bool

Source

pub fn shadow_url_defined(&self) -> bool

Source

pub fn relation_mode_defined(&self) -> bool

Source

pub fn schemas_defined(&self) -> bool

Trait Implementations§

Source§

impl Clone for Datasource

Source§

fn clone(&self) -> Datasource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Datasource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl WithSpan for Datasource

Source§

fn span(&self) -> Span

The span of the node.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.