TypeORM Crash Course - TypeScript & Node ORM
Вставка
- Опубліковано 5 сер 2024
- TypeORM is a great node ORM that allows you to create tables and perform CRUD operations with TypeScript & JavaScript. You can use it with multiple databases like MySQL, Postgres or MongoDB.
Postgres install:
www.postgresql.org/download/
Postico install:
eggerapps.at/postico/
GitHub Repo:
github.com/harblaith7/typeorm...
Timeline:
0:00 - Intro
5:35 - Setup
8:30 - Connecting to the DB
22:06 - Entities
43:45 - Relationships
1:01:30 - Inserting Data
1:15:15 - Forming Relationships
1:34:49 - Deleting Data
1:43:10 - Fetching Data
Awesome. I like the way you take your time to slowly explain everything in easy-to-understand detail.
Amazing tutorial, I was planning to dive into the documentation but this tutorial make my learning journey much much smoother, now I have the basics and I can check the docs to learn more
the way you explain any subject/topic/framework/language is exceptional, keep the good work up mate! wishing you all the best.. you're a top level teacher.. and then again, your consistency is excellent!
Very much appreciated lecture!! i didn't have a lot of information on TypeORM, so this was very enlightening!!
Halfway through, just said to to say thank you for putting this up and yes, even if we can't see it, we will take your word for it
Excellent explanation about TypeORM. What a powerful tool to model and make transactions in any type of database. Thank you for creating such amazing video.
just Great, I discovered this channel since a week ago, I think it's a geat channel, I learned NestJS from scratch with you Laith. I'm waiting for a project that combines nestJs and typeORM, thank you a lot :)
Wonderful crash course!!! Thanks so much Laith Harb.
Thanks so much! Really an Excellent tutorial, ;-) I didn't know much about decorators, so TypeORM all seemed kind of magical coming from Sequelize. But this really does seem a lot more simple in the long run. Cheers to you!
Exceptional tutorial! I've just started to learn PERN Stack project and currently adopting your tutorial into my own project. Despite some of the syntaxes are already deprecated, I can still managed to complete the project! Thanks
Which of the syntaxes are deprecated?
One of the best yt channel for developers . Thank you :)
Thanks, Laith. I'm really like your way to explain everything. Awesome!!.
Thank you so much for this amazing tutorial! Highly appreciated.
Just found a gem on the UA-cam, right on man, great course❤
Fantastic, thanks for making this tutorial which brought me many insights on relationships
Thanks for a simple and straight forward tutoral 😎💯👌🏾
that is one hell of a crash course! thanks
that was really enjoyable, I've learnt a lot from you thanks, I'm coming from a mongoose background and it is kinda the same at some points, again thanks a million Laith 💚💚
amazing hope all tutorials on youtube just like your tutorial
Excellent tutorial, thank you very much for sharing it!!!
mastered type orm with this single video thanks bro ....
This chan is just a fckn treasure!!! Thank man.
Thanks for timestamps!
Great lecture, thanks mate!
Great work keep going forward… hope next course is restful api using nodejs
Would really be interesting like 10-15min video , showing the right way to use the environment variables, and maybe a .env.example file or sth!!
Thanks in advance!
Always love you!!!!
Thank you!
thank you so much for this amazing tutorial.
Thanks, your explanation is very good.
Excelente tutorial, gracias por compartir!
thank you from Thailand 🙏🙏🙏
Quite great and simplified
@Laith Harb. I see you get some suggestion from vscode when trying to specify a type in the column decorator. Please is it an extension?? If not, how do I get the same functionality in my vscode editor?
You are amazing , explain very detail.
Very good stuff thank you for teaching us
Hi Laith, thanks for your astonishing video, if possible, please make a video for mongodb using mongoose in a practical app same as you did in this video for typeorm .
Really love this channel can u do a crash course on reactJS and ExpressJS
GreafFull tutorial, thanks
Amazing tutorial! Off to learning SQL now. A bit backwards, I know.
To solve the error of _'ts-node' is not recognized as an internal or external command, operable program or batch file_ use this in package.json file:
_"dev": "nodemon --watch \"./**/*.ts\" -e ts --exec \"npx ts-node src/index.ts\""_
Thanks
Thanks
u da man, thx. one love
Great video , but i have some remarks:
why you didn't use typeorm cli which help bootstrap the app and help generate entity / migration ... ,
and you didn't add the reflect-metada which is required by typeorm at least in the docs
Hi Laith Harb, how would you compare TypeORM with Prism ?
like definitely. Thank you
Amazing!
Thanks a lot my brother
Hey Laith, how are you doing? I appreciate the content. Its been very helpful. One question though: at 1:32:06 you try to save the [ ...banker.clients, client ], and get an non-iterable error. I got that, and understood what you did to fix, BUT, if I try to create a new many to many relation it only overwrites whatever is in the JoinTable, and does not create a new relation. I was wondering how could I fix that? I tried to POST instead of PUT, I tried to concat but its not working.
Hey! It's because in this case you write every time not append. Try banker.clients.push(client)
@@therealhramov This is incorrect, the push and the spread achieve the same things, the problem is that the clients array is currently not accessible from the banker object you have fetched., hence banker.clients is null here.
You have to add the 2nd argument in the form of any object to your @ManyToMany decorator in your Banker entity file -> the object being {cascade: true, eager: true}
thanks a lot brother
If transaction amount concatenates with client balance as string and not adds as number, do this:
_const numberAmount = Number(amount)_ and _Number(client.balance.toString())_
Thank you
hi, can we achieve one-to-many/many-to-one relation using TypeORM: select table1.*, table2.*
from table1 left join table2 on table1.pk_id=table2.fk_id and table1.status=1 , here main concern is to join table with multiple condition , thanks
nice tutorial
Thanks Laith - great video. Can you explain why despite defining the balance column type as 'numeric' and the field as a 'number' it is ultimately being treated as a string?
yeah it behaves weird. But just keep initial value to 0. Then deposit/withdraw will work fine.
1:34
The way you did it, it will always update the table and only add the banker and client relation passed at that time and will remove the older one, although it should keep all the record.
That example in 59:15 was confusing. Could you please clarify the @joinColumn command?
Man, thats a great tutorial! Touching a lot of aspects, very informative, nicely explained. Even such a stupid asshole as me got all the things clear.
thanks, this great, this is helpfull
Thanks
Amazing tutorial. Some sections need an update of some deprecated functions...
Great video. Thank you for this. A humble request though. At 01:24, There are 2 save actions. First for the transactions object and then for the client object. I know this is better done with a DB transaction. Can you add a chapter for DB atomic transactions using TypeORM into this course please?
why did you do banker.client = client? what if there is a new client for the same banker?
[npx tsc --init] to auto-generate tsconfig.json file. thank you for sharing the lesson.
Hello, I am running into the following right at the start "''ts-node'' is not recognized as an internal or external command,
operable program or batch file." any help would be great!
Try installing ts-node globally with:
npm install -g ts-node
FIXED: If you are using Windows at @13:03 instead of using single quotes within the dev you have to use (\"), thus looking like this "nodemon --watch \"./**/*.ts\" --exec \"ts-node\" src/index.ts"
@@APerson-d5s thanks man
Does this code include whole backend?
I don't understand why you define JoinTable in Banker entity and not in Client entity ? What is rule for that ?
This was so tough. The createConnection() function is outdated, I can't even connect to my database and there's no error that is caught when trying to do so. Even 'node --watch' doesn't work when tryong to connect to the database. There's no explanation on how to set up the database using the simple pgAdmin app. Everything from the beginning was just a mess. Correct me if I'm wrong. I'm open to anything that will make my connection work for me to learn typeORM. Other than that, here's where I give up with trying to use SQL in NodeJS
how make a controller there are 4 method: getAll , create , update , delete from repository ?
is there anybody who knows how to get ( find out ) username in postgreSQL if you are using windows ?
you did a perfect job sir...but the caption in your video reads typeORM=typeworm
🔥🔥🔥
it do not support dgraph database connection , hope they can solve it quickly
what is your database client name ?
Good
If you are watching this, after this comment was posted, createConnection is deprecated, now you need you use new DataSource
first install all the dependencies and then in your cmd,
write typeorm init --name project_name
where project_name is the name of ur choice,
if doesnt work then use this same command with npm
this will give you the whole template
thank you!
Why this is free...?
Thank you very much!
and I thought we were about to get sentimental @ 43:45
createconncection is not working
Please do Vue3 crash course and how to deploy it
hi sir alternatives for windows postgres server
pgAdmin
@@debarghyachakraborty thabks buddy
"Whoat eees an uoooramm?"
Very good tutorial, but a little out dated. Are you planning on updating this one?
you not perform any query to manytomany relation.
I was thinking of the same thing, why would someone skip that part when it's such a common usecase?
Anyways, good tutorial overall, thanks Laith.
ho about polymorphic relationship
Be careful with synchronize option and don't use this in production - otherwise you can lose production data
1:34:45
0:16:00
I think the many-to-many relationship is taught incorrectly here. Not getting the expected output also the logic doesn't make sense.
This typeorm is forcing really bad practice. Inherit classes on 2 levels. This is not ok.
15 min in the video and already encountered the issue in dev script and looking at the comments, it doesn't look like it will go well. I will try to install the exact packages version and see if I can make it work.
Anyway, to solve the error of 'ts-node' is not recognized as an internal or external command, operable program or batch file, use this in package.json file:
"dev": "nodemon --watch \"./**/*.ts\" -e ts --exec \"npx ts-node src/index.ts\""
The deault username for postgres in windows is "postgres"
thanks a lot brother
Thanks