This example shows how to use Photon.js in a simple Node.js script to read and write data in a database.
Clone the repository:
git clone git@github.com:prisma/photonjs.git
Install Node dependencies:
cd photonjs/examples/javascript/script
npm install
To run the example, you need the Prisma 2 CLI:
npm install -g prisma2
For this example, you'll use a simple SQLite database. To set up your database, run:
prisma2 lift save --name 'init'
prisma2 lift up
You 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
.
Run the following command to generate Photon.js:
prisma2 generate
Now you can seed your database using the seed
script from package.json
:
npm run seed
Execute the script with this command:
npm run start
- Read the Prisma 2 announcement
- Check out the Prisma 2 docs
- Share your feedback in the
prisma2-preview
channel on the Prisma Slack