Тёмный

Learn knex.js with Postgres and express in 35 minutes 

Jan Goebel
Подписаться 12 тыс.
Просмотров 48 тыс.
50% 1

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@benmar000
@benmar000 3 года назад
I really like that you take the time to explain how the setup is done in a real world context using best practices. Other channels are less helpful because they use quick and dirty methods that are not good for production. Thanks!
@jgoebel
@jgoebel 3 года назад
thx, I'm glad you got some value out of it 👍
@kiliusz
@kiliusz 6 месяцев назад
Agree :)
@mshowkat5321
@mshowkat5321 3 года назад
there aren't that much video about knex js. so far you video is the best about this topic. make a video play list for beginner also. that would help tons of people.
@jgoebel
@jgoebel 3 года назад
thx for the idea. Will add it to my list of potential topics 👍
@jgoebel
@jgoebel 3 года назад
What do you think about this video? Let me know in the comments.
@chibuokemibezim7402
@chibuokemibezim7402 3 года назад
This is a great tutorial, very helpful one, the fact that you also use best practises as much as you can while on it is great
@jgoebel
@jgoebel 3 года назад
thx, I'm glad it was helpful 👍
@abdulazeez.98
@abdulazeez.98 Год назад
I rarely see a video discussing best practices, most tutorials just do the whole thing in-line. Really appreciate it 👍
@PfalzerGbr
@PfalzerGbr 3 года назад
Great video, huge help for me as a beginner. I tried to implement layers by myself before, this one managed to clarify it even more. Amazing to see videos where the structure is not dumbed down, just because the example is simple. Thank you for your work!
@jgoebel
@jgoebel 3 года назад
thx Gabor, I hope it helps 👍
@EricOnYouTube
@EricOnYouTube 2 года назад
You showed how to build using the migrations. Nice would have been how to destroy and how to add to migrations after there are changes while already in production.
@jgoebel
@jgoebel 2 года назад
Hi Eric, you never destroy or delete migrations, you only add new migrations that might undo changes you did before. And even then, it is rare to delete columns. If you were to change the migration history, web servers can crash in spectacular ways. Because for example migration 3 now is not doing the exact same thing ans 2 weeks ago because you modified the migrations a few days back
@EricOnYouTube
@EricOnYouTube 2 года назад
@@jgoebel Thank you for the information.
@FirstLast-gk6lg
@FirstLast-gk6lg 2 года назад
It doesn't work. I have spent the last 3 days troubleshooting PostgreSQL & PGAdmin, I absolutely cannot get this to work. I have worked through dozens and dozens of possible solutions and I ALWAYS have yet another error. I cannot run the command migrate:latest and I cannot seem to get my PGAdmin to cooperate. This is my least favorite part of being a programmer, all of this software worked the last time I used it just a few months ago. All of it worked without issue. Now a few months later I attempt to do the exact same things I did back then and absolutely nothing will work, the simplest commands then simplest steps, nothing is working. I fucking hate this feeling
@jeremyAr
@jeremyAr 8 месяцев назад
Whats the purpose of dropping the table? In knex migrations.
@dnyaneshkale8293
@dnyaneshkale8293 2 года назад
thank you brother this was very neat. Do you also have any tutorials on PEAN stack?
@neilarmstrong8927
@neilarmstrong8927 2 года назад
Hello! I’m novice and don’t understand how you logining in adminer. Can you explain it please
@AhSoh7091
@AhSoh7091 Год назад
could you share some idea that how unit test for this? i watched your another video for the dependancy injection but still not idea how to implement into this
@sebastianionel5134
@sebastianionel5134 3 года назад
Uhh... yeah, as a beginner I am really confused right now and the fact that you have a person.js in ~4 folders and 2 indexes.js made this video harder to me to understand. Some of your commands didn't work for me so I needed to research by myself to find out what is the right command. Maybe it s because I am a newbie. And at the end I cannot escape from this error: UnhandledPromiseRejectionWarning: Error: Unable to acquire a connection
@jgoebel
@jgoebel 3 года назад
Hi Sebastian, your error looks like something is wrong with your database connection. Did you update the credentials in db/knexfile.js? Did you make sure your local db is running? If you look at package.json I added the migration command as a script there so you can copy and paste it if needed.
@toufikurrahmantoufik5368
@toufikurrahmantoufik5368 2 месяца назад
Thank You so much . I have complete a task. by following for video.
@jgoebel
@jgoebel Месяц назад
glad to hear!
@tahersaid2431
@tahersaid2431 2 года назад
This error shows up while using the post method:An error occurred while creating new person error: password authentication failed for user "postgres"
@jgoebel
@jgoebel 2 года назад
seems like either your password is wrong or the user you are trying to use ("postgres") does not exist.
@jackjones5207
@jackjones5207 7 месяцев назад
Best knex video... thanks Jan 🙂, keep up your good work
@jgoebel
@jgoebel 6 месяцев назад
Glad you enjoyed it!
@BelegaerTheGreat
@BelegaerTheGreat 3 года назад
At 12:00 I have an error: unknown option '--migrations'
@jgoebel
@jgoebel 3 года назад
Hi Kazik, did you use the exact command: npx knex migrate:make init --migrations-directory db/migrations
@nosmoke98
@nosmoke98 3 года назад
I had the same problem. Solution: Uses "cd .." and reuses "npx knex migrate:make init --migrations-directory db/migrations"
@a10gamerr
@a10gamerr 3 года назад
Thank you so much for the knex crash course. Would you please explain more about the service layer? Should the validation logic be added in the service layer and error response in the controller? Thanks!
@jgoebel
@jgoebel 3 года назад
In the service layer, you would add any business logic, e.g. making a REST call to anotherr web service (e.g. sending the reset password email, checking if password hashes match) Basically the "actual" business logic. And in the controller, you would just group together the different REST endpoints so that you don't implement them in the routes directory. If the service is simple, then you can leave out the controller level or even the service layer. As the code base grows and as you want to test more things independently, putting the logic inside of services makes more and more sense imo.
@ZachBradyisBrachZady
@ZachBradyisBrachZady 2 года назад
@@jgoebel do you have any videos focusing on Express server design using these abstractions? i.e.. DAO, service, controller
@olipaype
@olipaype 2 года назад
I´ve really tried to check every single line of your code... basically I've copied all but, when i try to seed an error emerged and said that the role does not exist.... referencing my "general" user instead of database assigned user--- I would appreciate any help
@opmHebat0404
@opmHebat0404 2 года назад
How to give a value each field before I run migartion? Example id int(5) name varchar(25)
@damonwu8018
@damonwu8018 3 года назад
Nice one, love the folder structure !!!
@jgoebel
@jgoebel 3 года назад
thx damon 👍
@ヒマワリ-y4z
@ヒマワリ-y4z 2 года назад
This is a great tutorial, very helpful one, Thanks a lot! I really appreciate you if you could tell me more about reference information regarding to patch and delete method in dao layer. I struggled to implement such methods as using req.params.id or req.body in dao layer but I couldn't figured it out... when I put arguments in dao layer to set id or update value, they are undefined. I want to know how I could pass req.params.id or req.body to service layer and dao layer.
@htouqeer938
@htouqeer938 2 года назад
I really like that you take the time to explain how the setup is done in a real world context using best practices. How can I complete CRUD in this. Please replay
@FriedRiceNigguh
@FriedRiceNigguh 3 года назад
This is lit
@jgoebel
@jgoebel 3 года назад
👍
@paulywill
@paulywill 2 года назад
Would there be much change to add GraphQL to this example?
@TawfikShalash
@TawfikShalash 2 года назад
so premium content
@jgoebel
@jgoebel 2 года назад
thx
@vikymuhamad4226
@vikymuhamad4226 3 года назад
how to put id in PersonDao when update person ?
@russellp.4005
@russellp.4005 3 года назад
Why did you destructure the createPerson as [id] at your dao? Isn't what returns an object? Also, does it have an id property?
@jgoebel
@jgoebel 3 года назад
Hi Russel, id is the primary key of the table and it is autoincrement. So the database generates the number for us when a record is inserted. You only know the id after the record was inserted. That's why it is very common to use UUIDs as primary keys because then you know the id upfront. But UUIDs as primary keys are little bit harder to understand, that's why I use integer and autoincrement as primary key. The returning method is also specific for Postgres. On MySQL it would be different: knexjs.org/#Builder-returning
@maltman126
@maltman126 3 года назад
Thanks for this...good video that was well explained. I'm a bit of a newbie, and and had to pause a few times....but at the end it worked!!
@jgoebel
@jgoebel 3 года назад
thx Matt, I'm glad you found it useful 👍
@omidnejadabbasi2171
@omidnejadabbasi2171 2 года назад
really good video!. I am a junior and i learn a lot from this video. please keep this up.
@jgoebel
@jgoebel 2 года назад
thx Omid
@PlayRiteProductions
@PlayRiteProductions 3 года назад
Thank you so much for this video bro. Best knex tutorial I've seen so far.
@jgoebel
@jgoebel 3 года назад
Thx, I'm glad it helped 👍
@LuthfanMursyidanM
@LuthfanMursyidanM Год назад
Very nice
@jgoebel
@jgoebel Год назад
thx
@Mi-rinconcito
@Mi-rinconcito 2 года назад
Thank you for this tutorial. I like the way you explain, very clearly. 🙏🙏
@jgoebel
@jgoebel 2 года назад
thx, I'm glad you found it useful 👍
@teckyify
@teckyify 3 года назад
Looks like an overkill of abstraction which Oren Oeini addresses all the time. You have an ORM which already abstracts away your data access. At least selects can be executed directly on the ORM.
@jgoebel
@jgoebel 3 года назад
you could, but what happens if you change the ORM? In that case you would need to refactor the whole code. If you encapsulate it in a dedicated layer, you only have to change that layer
@teckyify
@teckyify 3 года назад
@@jgoebel each query I have is tailored for one route and I don't reuse them because it would be semantic nonsense. And if (this is a big if in enterprise) I would switch the ORM, then I have still only unique places that need to be modified.
@jgoebel
@jgoebel 3 года назад
@@teckyify I think the idea is to not use knex or the db package in a lot of different locations. This makes it easier to refactor and test. If you have all db logic in one layer, you can easily stub this layer if you are testing something other than the db access.
@gustavobraganti5547
@gustavobraganti5547 3 года назад
Thank you very much for this tutorial! It helped me a lot! Keep up the good work!
@jgoebel
@jgoebel 3 года назад
thx Gustavo 👍
@cbton_
@cbton_ Год назад
Great tutorial, thank you so much.
@jgoebel
@jgoebel Год назад
thx
@invalidred
@invalidred 2 года назад
Thanks dude was great intro to knex, learned a lot
@jgoebel
@jgoebel 2 года назад
Glad I could help
@developerfriendly
@developerfriendly 2 года назад
perfect tutorial. thanks a lot!
@jgoebel
@jgoebel 2 года назад
You're welcome!
@davidgan298
@davidgan298 2 года назад
Super helpful, thank you!
@jgoebel
@jgoebel 2 года назад
you're welcome David!
@fahadsid
@fahadsid 3 года назад
This is a very nice tutorial.
@jgoebel
@jgoebel 3 года назад
thx Fahad, I'm glad you liked it 👍
@Fullflexno
@Fullflexno 3 года назад
Solid video!
@jgoebel
@jgoebel 3 года назад
thx Fullflex 👍
@emyboybeats4330
@emyboybeats4330 3 года назад
Thanks for this tutorial, your a life saver
@jgoebel
@jgoebel 3 года назад
Hi Emyboy, I'm glad it helped! 👍
@Gallagan
@Gallagan 3 года назад
Really Great content ! thanks man !
@jgoebel
@jgoebel 3 года назад
thx Gallagan, I'm glad you liked it!
@microwavecoffee
@microwavecoffee 3 года назад
thank you!
@jgoebel
@jgoebel 3 года назад
you're welcome 👍
@orkhan9999
@orkhan9999 3 года назад
thanks a lot
@jgoebel
@jgoebel 3 года назад
thanks Orkhan, you're welcome 👍
@viekva
@viekva 2 года назад
horrible
@SemenAlexndrovich
@SemenAlexndrovich 2 года назад
Great job! Thank you! Actually you are one of the few youtubers, who makes projects with proper structure
@jgoebel
@jgoebel 2 года назад
Glad you like it!
@boris-ilic
@boris-ilic 2 года назад
@@jgoebel Must say exact same thing, I feel your tutorials are production-oriented, all tutorials are top notch
Далее
▼ КАПИТАН НАШЁЛ НЕФТЬ В 🍑
33:40
Просмотров 485 тыс.
Learn Express JS In 35 Minutes
36:03
Просмотров 817 тыс.
I tried 8 different Postgres ORMs
9:46
Просмотров 414 тыс.
Microservices with Databases can be challenging...
20:52
Node winston logging | logging in Node
28:34
Просмотров 43 тыс.
10 JavaScript Interview Questions You HAVE TO KNOW
13:41
Up and Running with SQLite3 in a NodeJS API
47:16
Просмотров 2,7 тыс.
Sequelize ORM Tutorial (all in one video)
49:59
Просмотров 163 тыс.
How to build a REST API with Node js & Express
58:40
Просмотров 1,7 млн
▼ КАПИТАН НАШЁЛ НЕФТЬ В 🍑
33:40
Просмотров 485 тыс.