Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prisma/read-replicas-demo
https://github.com/prisma/read-replicas-demo
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/prisma/read-replicas-demo
- Owner: prisma
- Created: 2023-08-23T14:56:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-29T17:22:08.000Z (8 months ago)
- Last Synced: 2024-04-29T18:38:05.345Z (8 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Read Replicas example
This example shows how to use database replication using the [`@prisma/extension-read-replicas`](https://github.com/prisma/read-replicas-extension) extension in [Prisma Client](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client) in a **simple TypeScript script** to read and write data in a PostgreSQL database.
## Getting started
### 1. Download example and install dependencies
Clone this repository:
```bash
git clone [email protected]:prisma/read-replicas-demo.git --depth=1
```Install npm dependencies:
```bash
cd read-replicas-demo
npm install
```### 2. Create the database
Run the following command to create your PostgreSQL database file. This also creates the `User` and `Post` tables that are defined in [`prisma/schema.prisma`](./prisma/schema.prisma):
```bash
npx prisma migrate dev --name init
```### 3. Run the script
Execute the script with this command:
```bash
npm run dev
```## Next steps
- Check out the [Prisma docs](https://www.prisma.io/docs)
- Create issues and ask questions on [GitHub](https://github.com/prisma/prisma/)