1.0.1 • Published 6 years ago
photon-ve v1.0.1
Simple TypeScript Script Example
This example shows how to use Photon JS in a simple TypeScript script to read and write data in a database.
How to use
1. Download example & install dependencies
Clone the repository:
git clone git@github.com:prisma/photonjs.gitInstall Node dependencies:
cd photonjs/examples/typescript/script
npm install2. Install the Prisma 2 CLI
To run the example, you need the Prisma 2 CLI:
npm install -g prisma23. Set up database
For this example, you'll use a simple SQLite database. To set up your database, run:
prisma2 lift save --name 'init'
prisma2 lift upYou can now use the SQLite Browser to view and edit your data in the ./prisma/dev.db file that was created when you ran prisma2 lift up.
4. Generate Photon (type-safe database client)
Run the following command to generate Photon JS:
prisma2 generateNow you can seed your database using the seed script from package.json:
4. Seed the database data with this script
Execute the script with this command:
npm run seed5. Run the script
Execute the script with this command:
npm run startNext steps
- Read the Prisma 2 announcement
- Check out the Prisma 2 docs
- Share your feedback in the
prisma2-previewchannel on the Prisma Slack
1.0.1
6 years ago