Database Workflows & API Development with Prisma

Rate this content
Bookmark

Prisma is an open-source ORM for Node.js and TypeScript. In this workshop, you’ll learn the fundamental Prisma workflows to model data, perform database migrations and query the database to read and write data. You’ll also learn how Prisma fits into your application stack, building a REST API and a GraphQL API from scratch using SQLite as the database.


Table of contents:
- Setting up Prisma, data modeling & migrations

- Exploring Prisma Client to query the database

- Building REST API routes with Express

- Building a GraphQL API with Apollo Server

This workshop has been presented at Node Congress 2022, check out the latest edition of this JavaScript Conference.

FAQ

Prisma is an Object Relational Mapper (ORM) that allows you to work with a relational database from an object-oriented programming language. It maps the data structures from the relational database into the object-oriented programming language, offering a type-safe database client for querying. Prisma differs from traditional ORMs by using a schema-based approach to model data and generate queries, providing a more intuitive and developer-friendly API.

No, prior knowledge of SQL or TypeScript is not required to start using Prisma. The workshop and resources provided by Prisma are designed to introduce you to all the necessary concepts from scratch, making it accessible for beginners.

In the workshop, you will learn the essential workflows for building an application using Prisma. This includes setting up Prisma with a SQLite database, data modeling, performing database migrations, and using Prisma Client to implement REST and GraphQL APIs. The workshop is structured into hands-on lessons that also cover querying databases and integrating Prisma into web applications.

Yes, the materials provided in the Prisma workshop, such as the Notion document, are freely available for reuse. You are encouraged to use these materials to host your own workshop sessions, whether to educate colleagues or friends interested in learning about Prisma and database management.

If you encounter issues with opening the Notion document during the workshop, the host can export the document as a PDF and share it with participants. This ensures everyone can access the content and follow along with the workshop tasks.

Prisma Client is a type-safe query builder used to facilitate direct operations on your database. It allows you to perform CRUD operations, run queries involving relations, filters, and pagination, and integrates seamlessly into your application to manage data effectively.

Prisma provides connectors for various databases including PostgreSQL, MySQL, SQLite, and SQL Server, among others. It allows developers to define their data model in a Prisma schema file, which abstracts the database-specific configurations and enhances cross-database compatibility and migration workflows.

Nikolas Burk
Nikolas Burk
98 min
14 Feb, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Welcome to the Database Workflows and API Development with Prisma workshop. Prisma is an ORM that allows you to work with a relational database from an object-oriented programming language. The workshop covers topics such as data modeling, migrations, using Prisma Client for querying the database, and implementing REST and GraphQL APIs. It also highlights the benefits of Prisma, including its intuitive data modeling language, type-safe database client, and migration tool. The workshop provides hands-on tasks and guidance for beginners to get started with Prisma.

1. Introduction to Prisma Workshop

Short description:

Welcome to the Database Workflows and API Development with Prisma workshop. Today, I'll introduce you to Prisma and cover the most important workflows for building an application with Prisma. We'll start by setting up Prisma with a SQLite database, then learn about data modeling, migrations, and using Prisma Client for querying the database. We'll also explore implementing REST and GraphQL APIs using Prisma Client. No prior knowledge is required, as I'll provide the necessary resources and guidance. Feel free to ask questions and follow along as I explain each lesson before giving you time to work on the tasks. I'm Nikolas, the host of this workshop, and you can connect with me on Twitter, GitHub, email, or the Prisma Slack. This workshop is free for you to use and share with others.

Welcome to the Database Workflows and API Development with Prisma workshop. I'm really excited to give this workshop today. Actually, these kinds of workshop are pretty much the favorite part of my job as a developer advocate who works at Prisma to work with people and show them kind of their first steps with Prisma. And that's exactly what you'll be doing today. So no need for any prior kind of knowledge about SQL or TypeScript or anything. We'll start from scratch and I'll introduce all the relevant concepts so that you don't need to know anything upfront.

One thing that I would ask all of you to do is to take this link that I'm now also dropping in the chat and open it because then you can see also this Notion document that I'm using here right now. And just for logistics, I have a second screen here to my left where I'm monitoring the chat. So forgive me if I'm not always looking directly at you all. I'm just checking what's going on in the chat and if things don't work or if you have a question, you can always drop that in the chat or because as I already mentioned, we do a regular Zoom call here. You can also just unmute yourself and then ask a question. So that's definitely possible here as well. An issue that like Notion SO doesn't work for encrypting. I actually don't have another source. I didn't have problems so far with Notion, but it's also not too big of a deal if you cannot open it yourself because I will walk everybody through the document. And what I can do is I think I can export it as a PDF. I can do that later when you get to work on your first task and then I can send you over the PDF document. So we should be able to resolve that. All right. So welcome again, Database Workflows and API Development with Prisma. So what you're going to learn today is basically the most important workflows that you have to be aware of when you want to build an application with Prisma. And I'll explain in a little bit actually what Prisma actually is and what it does. But first I want to give you a rough overview of what we're covering in this workshop. So at first we start by setting up Prisma with a SQLite database. You learn about data modeling with Prisma and performing database migrations. Then you learn about Prisma Client, a typesafe query builder that can be used to query your database. And you're going to explore various queries there from plain CRUD to relation queries to filters and pagination. And next you'll learn how you can use Prisma Client to implement the routes of a REST API and then also the resolvers of a GraphQL API. And you don't have to know what a REST API actually looks like, what a GraphQL API looks like. I prepared kind of the boiler plate for you. The skeletons of the projects that you're going to be working with. So if you haven't heard of what a GraphQL resolver is for example, that's not a problem at all for this workshop. Ahem, so this is the high level agenda. Actually I realized that it's all one hour too early. So that should be like starting at four and then you add one hour each time. What does a lesson look like? So I prepared these four lessons that map to the different things that we want to do in the workshop. So setting up Prisma, data modeling and migrations, exploring Prisma Client, Rest API and GraphQL API are the lessons. And each lesson looks as follows that at first I'm going to give a walkthrough of the lesson. So for example, for the first one here, I click on it and then I'm going to explain what you are supposed to do in that particular lesson. And I'll even show you like here with my terminal, with my VS code, a little bit of the task that you're going to be working on. And after having shown you maybe three or four tasks per lesson, you'll get the time to work on the tasks of that lesson by yourself. And what I really want to emphasize for you all here to get the most out of this workshop is to not already code along when it's still me doing the walkthrough. So I think it's really best if when I show you what a lesson is going to look like, when I explain the individual tasks that you just pay attention and that you raise any kind of questions that cross your mind, but really focus on the things that I do, that I say, and try to understand that. And after that, you'll have plenty of time to actually finish these tasks yourself. So be a little bit patient when I'm explaining each task and each lesson and then you'll make the most out of the workshop for yourself.

My name is Nikolas, I'm the host of this workshop. I really like to educate other developers and as a developer advocate of Prisma, that's basically my main job. And you can follow me on Twitter, on GitHub, you can drop me an email or you can also find me on the official Prisma Slack. One final note before we dive into the topics is that this workshop, this like Notion document is completely free for you to use if you want to host this workshop for yourself at some point. So if you feel like what you've learned in this workshop today is really valuable and you would like to share it maybe with your colleagues or with friends and like maybe like some of them are up for like spending a few hours with you on this then you can just reuse all of these materials that I've put together here and use them when you're giving this workshop yourself.

2. Introduction to Prisma

Short description:

Before we start with the lessons, let me give you an overview of what Prisma is. We'll visit the Prisma website and explore the landing page together. Feel free to ask questions and join in the conversation about databases and object relational mappers.

All right, I think that's it with the overview for the logistics. All right, before we start with the actual lessons I would quickly like to give an overview of what Prisma actually is. And the way how I want to do that is actually just by going to the Prisma website and give you all a quick walkthrough over our landing page because I think that's probably most instructive here. And if you have any questions along the way also feel free to unmute yourself and drop in, I want to make this kind of as interactive as possible. And if we want to have a conversation here about databases and object relational mappers that's totally fine with me as well. So if anyone here actually has strong opinions about this topic, then feel free to join me here.

QnA