#Next.js and databases (Prisma, SQL...)
1 messages · Page 1 of 1 (latest)
Is Prisma what Bootstrap was to CSS? Just sort of a crutch for when you don't really know CSS?
what exactly is Prisma doing?
Prisma generates database schema
Prisma lets you design database and create type-safe interface
Prisma also lets you interact with DB without writing SQL. (Though you can still use SQL)
Do we need it to interact with a database?
No you dont need it. However you still need a connector/driver/api to connect to a database.
Should one still learn SQL to use a relational database inside Next.js?
Learn concepts rather than SQL. That would be more helpful rather than the SQL itself.
Id recommend the theory on Normalization
Is Prisma what Bootstrap was to CSS? Just sort of a crutch for when you don't really know CSS?
Bootstrap is not just "sort of a crutch" for when you don't really know CSS... Its more like a layer of abstraction.
very helpful, @deft pewter . Which approach you'd take to learn how to interact with databases inside Next.js from scratch? I built very basic Express CRUD apps years ago when learning web dev, but since then all my professional experience has been frontend.
Bootstrap is not just "sort of a crutch" for when you don't really know CSS... Its more like a layer of abstraction.
I see what you mean, my take was too broad.
I wanna explore the fullstack/backend possibilities of Next.js and having issues finding any resources teaching it. Everything either is focused on the frontend or it assumes previous backend knowledge and "yada-yada" (a-la Seinfeld) the small details.
what seems to be the problem with interacting with database?
its pretty straightforward if you use Prisma :v
no problem per se, I just wanna learn how to do it.
Assuming little to no experience with databases or backend, really
then just do it :D
prisma.car.create({name:"Toyoda", wheel: 4})
to be honest for most things prisma syntax suffices
i really recommend it for beginners
do you recommend any teaching resource (besides the documentation) ?
and then you can still use rawsql function if you need to do some more complex query
have you tried prisma?
i recommend using it with Typescript so you'd get autocomplete
and can learn as you code
I blindly followed a tutorial that assumed previous backend knowledge, so I didn't really understood much
how did you come to the conclusion that the tutorial "assumed previous backend knowledge"?
what kind of backend knowledge do you feel like ure missing when following the tutorial?
Sorry i dont have any tutorial so id figure id just help you here 😭
how did you come to the conclusion that the tutorial "assumed previous backend knowledge"?
It's just the vibe I got, tutorial spent 90% of the time explaining routing and other FE Next.js features and then for database interaction just dispatched a couple of commands with Prisma with no explanation or depth
I appreciate your help, just wanted to have some general holistic views on Prisma
yes
well an ORM maps tables and stuff into object-like syntax
instead of writing queries to get strings of data that you need to format,
Prisma ORM converts those into ready-to-use objects
why is it an ORM used with Next.js? When I built Express backends with Mongodb or SQL there was no ORM
there was
you can use Prisma in Espress
theres also TypeORM
but Prisma handles more than an ORM
Prisma also allwos you design the schema and have it generated on the real db
so you dont even need to write DDL anymore
what was DDL sorry?
if you write schema like this
model Car {
name String @id
wheel Int
}
then your prisma.car.findOne() will always return in the form of
{
name: string
wheel: number
}
the typings are already 1:1
DDL = data definition language, its the creating table part of SQL
ok, starting to make sense
so you can just
const car = prisma.car.findOne(...)
return car.name
:D
ORM = Object Relational Mapper
I really appreciate the time you've taken with this Alfonsus. I think I know enough what to research more about now. I'll come back if I still have doubts.
Have a great day!