Skip to content
/ prisma Public

Provides a fast and easy way to implement a NoSQL db provider in your project.

License

Notifications You must be signed in to change notification settings

p-brito/prisma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔺 Prisma

Build Nuget Apache License 2.0

Prisma provides a fast and easy way to implement a NoSQL db provider in your project.

Getting started

  • Install the Prisma package in your project.

  • Register the service in your Startup.cs.

  services.AddPrisma();
  • Add the PrismaOptions to appsetting.json and register these.
{
    "PrismaOptions":{
        "Provider":"",
        "ConnectionString":"",
    }
}
 services.Configure<PrismaOptions>(configuration.GetSection(nameof(PrismaOptions)));

Notice, that these options will change accordingly to the provider that you are using. Read the documentation on how to configure your provider below.

  • Get the provider
IPrismaProvider<TEntity> myProvider = this.serviceProvider.GetRequiredService<IPrismaProvider<TEntity>>();

The PrismaProvider has the following methods:

  • GetAsync
  • InsertAsync
  • UpdateAsync
  • DeleteAsync

Notice, that all the entities that are used need to inherit from BaseEntity.

Providers

MongoDB

  • First and if you do not have an account create one here.

  • Create your organization and after that your project.

  • Create a cluster. Create a cluster

  • Configure your cluster, defining if this is accessible to anyone or not, and adding a database user. Configure a cluster

  • Now, follow these steps.

  • Add the prisma options to your appsettings.json file, consider the following example.

    {
        "PrismaOptions":{
            "Provider":"MongoDb",
            "ConnectionString":"mongodb+srv://admin:mypass123@myddbcluster.c900q.mongodb.net/MyDatabaseName?retryWrites=true&w=majority"
        }
    }

DynamoDB

  • First and if you haven't, create an account here.

  • Follow these steps to configure your account, see this.

  • Create a new group. Create a group

  • Create a user, add it to the group that you have created, save the Access Key ID and the Secret access key you will need this later on.

  • Now, follow these steps.

  • Add the prisma options to your appsettings.json file, consider the following example.

    {
        "PrismaOptions": {
            "Provider": "DynamoDb",
            "ConnectionString": "accesskey=AKIATEJJHIIBH5Z6XUMA;secretkey=9VB7jBKQvdyNrVX5d2t+cD4UTwnW4Nc2f98vigHa;region=eu-west-1"
        }
    }

CosmosDB

  • First and if you haven't, create an account here.

  • Search for Azure Cosmos DB and create an account. Create a cosmosdb account

  • Click on keys and get your PRIMARY CONNECTION STRING. Get primary connection string

  • Now, follow these steps.

  • Add the prisma options to your appsettings.json file, consider the following example.

    {
        "PrismaOptions":{
            "Provider":"CosmosDb",
            "ConnectionString":"AccountEndpoint=MyEndpoint;AccountKey=myAccountKey;DatabaseKey=myDatabaseKey;"
        }
    }

Notice, that you can define the throughput in your connection string by adding the following parameter AutoscaleThroughput=value or ManualThroughput=value in the connection string. By default the value of the throughput is set to 4000 RU/s.

The AutoScaleThroughput, provisions the RU/s based on the workload between the range of 10% of Max RU/s to Max RU’s. Be aware that the cost of autoscale is 50% more than the standard throughput.

The ManualThroughput, use this to define a custom value for your throughput.

To know more about this consider this article.

Also, you can define the partition key by adding the following parameter PartitionKey=Name in the connection string. By default the partition key is the entity id.

About

Provides a fast and easy way to implement a NoSQL db provider in your project.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages