Node Objection.js tutorial with knex and Postgres | Node SQL ORM

preview_player
Показать описание


00:00 introduction
02:20 project setup
06:19 creating a knexfile
11:52 creating database schema migration
19:23 executing initial database migration
23:07 creating seed data with knex CLI tool
30:47 executing seed file
40:45 adding relation mappings
43:22 conclusion
Рекомендации по теме
Комментарии
Автор

What do think about Objection.js?
Let me know in the comments below

jgoebel
Автор

Amazing tutorial! Been struggling for days to understand knex and Objection and this totally did wonders for me, keep up the great content man!

borquez
Автор

thank you so much for this. knex documentation was so difficult to follow. i appreciate it

rawlespringer
Автор

Do we need a service and Dao layer when using graphql?

wesleymostien
Автор

Thanks a lot . Your tutorial patched up some missing areas in my way doing this.

saeeduchiha
Автор

Great tutorial. Really hope you do more on this. I'm coming from Rails and Objection seems pretty close to ActiveRecord. It's unfortunate there are so many tutorials that focus on NoSql. I mean c'mon, most data is relational. So cheers to you for putting this together!

fooked
Автор

Awesome. I have to try this with Typescript. Thanks for this nice tutorial.

ericaskari
Автор

Great video, thank you for sharing it.

It would be great if you could upload a second part to it showing how to create Routes, Services, and Controllers :)

Richard_Schmidt
Автор

Great tutorial. I am eager to try objection and knex.js. They seem solid and managable

alimertc
Автор

Thanks for such an amazing and well thought out tutorial!

mohantee
Автор

awesome awesome tutorial! I'd like to see more just like this! seeing how you do things RAW helps a lot!

ofeenee
Автор

detail explanation, I love it. thank you

Maman-Setrum
Автор

Thanks for the great video tutorial! Would love to see a Watermelon DB integration & sync with this! There's not a lot of tutorials out there online about WatermelonDB and even the existing ones don't usually cover sync

kristinlau
Автор

This tutorial was amazing, helped me a lot in figuring out how Objection and knex work.
Question: Do objection and knex work well with Typescript? Or would you recommend using some other ORM?
Thanks in advance!

sakethraman
Автор

It seems that running the migration with foreign keys (.references) without defining mappings first does not work

alter table "cards" add constraint "cards_id_user_foreign" foreign key ("id_user") references "users" ("id") - relation "users" does not exist

Maybe this can be solved with this :
//from docs

carlotadias
Автор

I am getting this error when executing knex migrate

migration failed with error: alter table `user` add constraint `user_channelid_foreign` foreign key (`channelId`) references `channel` (`id`) - Referencing column 'channelId' and referenced column 'id' in foreign key constraint 'user_channelid_foreign' are incompatible.

Note: I am using mysql

EDIT: temporarily made it work by replacing increments with integer

mugilancodes
Автор

Hey! So i am using sqlite3 as my db, when i try to use my user model in my index.js, it creates a new db in my root directory which is empty. I think the problem is at the knexfile
module.exports = {

development: {
client: 'sqlite3',
connection: {
filename: './my_knex_DB.sqlite3' // maybe should be './db/my_knex_DB.sqlite3'
},

somehow changing the filename/path when we are calling the db in db-setup work.

another way i thought of, would be to just use it as the did in the docs (this works)
const knex = Knex({
client: 'sqlite3',
useNullAsDefault: true,
connection: {
filename: './db/my_knex_DB.sqlite3'
}
});
Model.knex(knex);
However i dont know if this would be safe with using the migrations.
btw thanks for the tutorial really helped stream line the db calls and manage everything with the models

jagrat
Автор

Great tutorial. This video helps me a lot.
But I want to separate a folder which includes controller and only shows routes (endpoints) in server.js file. You can help me this.
Thank you.

tuannobi
Автор

please please please do more videos senpai! please! 🙏

ofeenee
Автор

This is brilliant! Thank you so much for sharing! How would you set this up with environment variables? Any pointers on that/suggestions?

VitorGuerreiroVideos