async fn new(config: Configuration, dm: Datamodel, legacy: bool, enable_raw_queries: bool) -> PrismaResult<Self> {
        let template = DatamodelConverter::convert(&dm);

        // We only support one data source at the moment, so take the first one (default not exposed yet).
        let data_source = config
            .datasources
            .first()
            .ok_or_else(|| PrismaError::ConfigurationError("No valid data source found".into()))?;

        let url = data_source.load_url(|key| env::var(key).ok())?;

        // Load executor

        let preview_features: Vec<_> = config.preview_features().cloned().collect();
        let (db_name, executor) = exec_loader::load(&data_source, &preview_features, &url).await?;

        // Build internal data model
        let internal_data_model = template.build(db_name);

        // Construct query schema
        let build_mode = if legacy { BuildMode::Legacy } else { BuildMode::Modern };
        let query_schema: QuerySchemaRef = Arc::new(schema_builder::build(
            internal_data_model,
            build_mode,
            enable_raw_queries,
            data_source.capabilities(),
            preview_features,
        ));

        let context = Self {
            query_schema,
            dm,
            executor,
        };

        context.verify_connection().await?;

        Ok(context)
    }
/// Initializes a new Prisma context.
Initializes a new Prisma context.
Initializes a new Prisma context .
async fn new(config: Configuration, dm: Datamodel, legacy: bool, enable_raw_queries: bool) -> PrismaResult<Self> {
        let template = DatamodelConverter::convert(&dm);
        // We only support one data source at the moment, so take the first one (default not exposed yet).
        let data_source = config
            .datasources
            .first()
            .ok_or_else(|| PrismaError::ConfigurationError("No valid data source found".into()))?;
        let url = data_source.load_url(|key| env::var(key).ok())?;
        // Load executor
        let preview_features: Vec<_> = config.preview_features().cloned().collect();
        let (db_name, executor) = exec_loader::load(&data_source, &preview_features, &url).await?;
        // Build internal data model
        let internal_data_model = template.build(db_name);
        // Construct query schema
        let build_mode = if legacy { BuildMode::Legacy } else { BuildMode::Modern };
        let query_schema: QuerySchemaRef = Arc::new(schema_builder::build(
            internal_data_model,
            build_mode,
            enable_raw_queries,
            data_source.capabilities(),
            preview_features,
        ));
        let context = Self {
            query_schema,
            dm,
            executor,
        };
        context.verify_connection().await?;
        Ok(context)
    }
async fn new ( config : Configuration , dm : Datamodel , legacy : bool , enable_raw_queries : bool ) -> PrismaResult < Self > { let template = DatamodelConverter :: convert ( & dm ) ; // We only support one data source at the moment, so take the first one (default not exposed yet). let data_source = config . datasources . first ( ) . ok_or_else ( | | PrismaError :: ConfigurationError ( " " . into ( ) ) ) ? ; let url = data_source . load_url ( | key | env :: var ( key ) . ok ( ) ) ? ; // Load executor let preview_features : Vec < _ > = config . preview_features ( ) . cloned ( ) . collect ( ) ; let ( db_name , executor ) = exec_loader :: load ( & data_source , & preview_features , & url ) . await ? ; // Build internal data model let internal_data_model = template . build ( db_name ) ; // Construct query schema let build_mode = if legacy { BuildMode :: Legacy } else { BuildMode :: Modern } ; let query_schema : QuerySchemaRef = Arc :: new ( schema_builder :: build ( internal_data_model , build_mode , enable_raw_queries , data_source . capabilities ( ) , preview_features , ) ) ; let context = Self { query_schema , dm , executor , } ; context . verify_connection ( ) . await ? ; Ok ( context ) }
Initializes a new Prisma context.
Initializes a new Prisma context .
config
Configuration
dm
Datamodel
legacy
bool
enable_raw_queries
bool