Post by account_disabled on Feb 25, 2024 4:04:53 GMT
DATA BASEREPLICA URL postgresdanielpasswordepdampcell useast2.aws.neon.replicas using prisma extensionrea dreplicas To start using read replicas in your application install the extension in your project npm install prisma extensionr eadreplicas COPY Next initialize the extension by extending your existing Prisma Client instance and pointing it to a database replica import PrismaClient from prisma client import readReplicas from prisma extensionrea dreplicas const prisma new PrismaClient .extends read Replicas url process.env.DATAB ASEREPLICAURL COPY If you wish to set up multiple replicas you can repeat the steps above to create additional replicas. Then update the read Replicas configuration in your application as follows libprisma.ts const prisma new PrismaClient .
The process.env.DATABASEREPLICAURL1 process.env.DATABASEREPLICAURL2 COPY And thats it When you run your app the extension will Switzerland Mobile Number List send all read operations such as findMany to a database replica. A replica will be selected randomly if you have multiple replicas defined. Any write queries e.g. create update ... as well as transaction queries are forwarded to the primary instance of your database which would consequently propagate the resulting changes to the existing database replicas. If you would like to read from the primary database and bypass read replicas the extension provides the primary method on your extended.
Prisma Client instance const feed await prisma.primary.post.find Many This Prisma Client query will always be routed to your primary database to ensure uptodate data. Why did we build read replica support as a Prisma Client extension A significant advantage of having the extension as a separate package rather than part of the ORM for now is that it allows us to ship improvements to the extension independently from ORM releases. Therefore well be able to refine the API as much as we need to ensure that the extension solves our communitys needs. A sideeffect of shipping it as a separate packagerepository is that the codebase will remain.
The process.env.DATABASEREPLICAURL1 process.env.DATABASEREPLICAURL2 COPY And thats it When you run your app the extension will Switzerland Mobile Number List send all read operations such as findMany to a database replica. A replica will be selected randomly if you have multiple replicas defined. Any write queries e.g. create update ... as well as transaction queries are forwarded to the primary instance of your database which would consequently propagate the resulting changes to the existing database replicas. If you would like to read from the primary database and bypass read replicas the extension provides the primary method on your extended.
Prisma Client instance const feed await prisma.primary.post.find Many This Prisma Client query will always be routed to your primary database to ensure uptodate data. Why did we build read replica support as a Prisma Client extension A significant advantage of having the extension as a separate package rather than part of the ORM for now is that it allows us to ship improvements to the extension independently from ORM releases. Therefore well be able to refine the API as much as we need to ensure that the extension solves our communitys needs. A sideeffect of shipping it as a separate packagerepository is that the codebase will remain.