I'll soon be starting a new job (or by the time you read this, maybe I've already started!) on the docs team at Prisma as a technical writer. That means I get paid to play around with Prisma and write about it, pretty sweet gig.
So, I start in 1 month and want to get learning, that, after all, is the fun part of the job, learning how things work then sharing the experience. I'll be documenting as I go so consider this my notes as I learn how Prisma works. I'm coming at this from the perspective of a developer, not someone who hasn't coded before, and my notes will reflect that. This won't be a walk-through, but I'm hopeful that someone out there will happen across it and find it useful.
What better place to start than a quick rundown of what Prisma actually is, this is super high level and by no means a deep dive. Prisma is a layer you place on top of your database which gives type safe ways to interact with your data. Your database is SQL based (think Postgres, MySQL). The Prisma client is a query builder for Node and TypeScript. To use it you instantiate a new instance of the PrismaClient class. It has a bunch of super handy methods for you to use to manipulate and interact with your data.
That example is taken from the awesome docs. Handy tip, Prisma has a vscode extension which will give you intellisense when writing your schema file, real nice.
So the models map to the tables in your database. You define what each column should be for data type and can set default values. It's from here that you also define the relationships each column or table has to another column or table.
Jumping back a second to take a look at how to use the client. This code block is from the introductory tutorial in the Prisma docs
The methods on the client let you use object syntax for querying your data. It feels very intuitive to write the queries this way. The
create() method uses a nested query which is made possible by the defined relationships in the schema. In the
findMany() method you choose which nodes to include in the returned data by using the key
includes and then setting some boolean values. Lovely!
I'm currently building a blogging CMS for my wife and was going to go with a headless solution for storing data. I've now had a re-think though and think it would be a great opportunity to use Prisma and test out some of the stuff it can do. My CMS frontend code is currently in Nextjs though Im by no means tied to that solution. The idea for the CMS is that the user will be able to write their blog posts in a sort of rich text format. This data will then be saved to a database and can be fetched using either REST or GraphQL to be shown on their frontend of choice. All this ties in nicely with Prisma and I should be able to create an authenticated backend service that will ideally live alongside the CMS code.