AnirudhSinghBhadauria/stereotype

How do you feed content?

Opened this issue · 4 comments

I love your work but I dont know how you feed content for dev? I try to feed your data into Prisma but cant get it running properly.

I appriciate your kind words, Actually when I made this project, I also wanted to make a admin page where we can add blogs, I haven't made it yet, eventually I will, For now I have made a seeding file (path: src/utils/seeding.ts) which has a prisma function that adds blogs to particular models in the database. Basically I added blogs to database via prisma programatically. Please have a look at that file. I am using a sql database (planetscale). For better understanding I am giving you a gist that contains different models and how they look inside of databse that will help you model your database.

Data models in Sterotype - https://gist.github.com/AnirudhSinghBhadauria/50703c894e709d2806a717ce7dcdf0c7

Just model your databse accordingly using these definitions then you would be able to do it! Hope I resolved your issue!

Sorry for late response,

Why I didn't had one model representing all the different kind of blogs -

  1. Those three varients of blogpost have their different props and attributes, therefore, I made three different schemas mapping to three different relations in my database.

  2. I could have integrated all the different varients of blogs in one model but, then there would have one big model with all the blogs in it. Now, the problem is traversing a big model is exprensive than traversing a smaller one, its like traversing 10 entries vs traversing 100. That would have resulted in bad database query times and it would largly affected the performence of the app.

  3. for integrating these three models, we could just make one schema that would contain all the props of all kind of blogs.
    Now If we wanted a particular type of blog, we would only fill data of that blog and leave all the other props null, now using some conditional statements we could have figured out how to display a particular type of blog. I am not an expert and I am also trying to learn how things work, but that doesn't sound like a great idea to me. Hope these explainations made sense.

Coming to the second part,

As I said I am not an expert, but my suggestion would be that you should read documentation of Prisma. I know it maybe a little boring to read the whole documentation, but we dont need to do that (for now at least). For now learn how to connect prisma to db of your choice, how to use prisma on client side (prisma cli), how to visualize db using prisma (prisma gui), how to do CURD operations using prisma. and that good enough for starting learning prisma, as your confidence increases we can gradually learn some advance stuff. If you're stuck at any place, you can always ask chatgpt for the answer, googling always helps!

If you're using a postgres database, first make sure you have configured your .schema file properly.(https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/relational-databases/connect-your-database-node-postgresql)

for any seeding related issue read this,
https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding

Hope this helps,
Thank you!

hye,

thank you for responding. may i know why the need to have an api route when we can pull data from component?

sorry for bugging you

appreciate your feedback