This Node.js example uses the Prisma Client in a simple Node.js script to write, update and read data from a mysql database. Mysql database runs locally on localhost:3306 ports.
The example was built on top of this javascript script provided by Prisma.
The script is a simple CLI to perform some basic operations on the DB through the Prisma Client. The actions are specified by the argument passed together with the node command to start the script.
Recreate the Characters DB using the SQL dump on your mysql server on your machine. The DB has a single table called "character". It will be filled with some Game of Thrones characters coming from an array built in the script.js file.
Clone this repository:
git clone [email protected]:carmelag/GOT-js.git
Install npm dependencies:
cd GOT-js
npm install
npm install should install Prisma Client JS into node_modules/@prisma/client
via a postinstall
hook of the @prisma/client
package from your package.json
.
Anyway, if you have issue with this and get an error message related to missing Prisma Client, please run the following commands:
npm install -g prisma2
prisma2 generate
Execute the script with these commands:
npm run dev writeDB
Write an array of Game of Thrones Characters to the DBnpm run dev updateDB
Find out the real name of Jon Snow (Spoiler Alert!)npm run dev readDB
See all the characters stored within the DB