TypeORM Relations Tutorial - FULL details!

Поділитися
Вставка
  • Опубліковано 8 вер 2024

КОМЕНТАРІ • 248

  • @mariusespejo
    @mariusespejo  2 роки тому +21

    Note: TypeORM just released v0.3 which has some breaking changes on how you query relations, e.g. instead of an array of strings for find() you now use an object. Make sure to check the release notes and docs! Most of the fundamentals in the video still applies though.

    • @andifaizal6848
      @andifaizal6848 2 роки тому

      Can you explain about V0.3 and what is changes in typeorm?

    • @andifaizal6848
      @andifaizal6848 2 роки тому

      Thank you

    • @andifaizal6848
      @andifaizal6848 2 роки тому

      @UCDpd-qEwAI9wglx4tsEBAtw how about changes creatConnection to dataSource?
      I have a project with install quick start and i can't see change about createConnection to dataSource?
      Can explain with this problem about quick start.

    • @mariusespejo
      @mariusespejo  2 роки тому +2

      I suggest reading their release notes in github, it’s a lot to explain in a comment

    • @andifaizal6848
      @andifaizal6848 2 роки тому

      @@mariusespejo Okay. Thank you for advice. I'm go to github.
      You're really good to explain. Thank you for that.🙏

  • @gilsonviana4936
    @gilsonviana4936 2 роки тому +1

    You've exposed TypeORM with great eloquence and simplicity.

  • @alexandermarthius5593
    @alexandermarthius5593 3 роки тому +6

    another great tutorial, learning Typorm never been so easy before!
    Thanks you so much Marius

  • @josephsamuel3254
    @josephsamuel3254 Рік тому +1

    Your channel is the best source of information on NestJs and TypeOrm , Keep up the good work👍

  • @iansamz
    @iansamz 3 роки тому +2

    Just when I was about to give up on nestjs. You showed up. Thanks alot

  • @James-fe7wd
    @James-fe7wd 3 місяці тому

    Bro, thank you for laying this out in such a clear and concise way. I've been struggling with typeOrm for a while now, and I finally decided to come and seek help. Silly devs like me who don't have the time to go through the documentation still try stabbing in the dark to figure it out which is far more time consuming. But I had no idea I could learn so much so quickly from anyone on the subect. Kudos!

    • @mariusespejo
      @mariusespejo  3 місяці тому +1

      Thanks for the comment! Glad this old video is still helping folks out!

    • @James-fe7wd
      @James-fe7wd 3 місяці тому

      @@mariusespejo In a big way!

  • @alirahimi4746
    @alirahimi4746 7 місяців тому

    THANK YOU! ❤❤ this is what i needed all these times, a basic in depth tutorial on why and how to use the relationships in typeorm

    • @mariusespejo
      @mariusespejo  7 місяців тому

      It’s an old video but glad it’s still helpful!

  • @shabbirhusain6634
    @shabbirhusain6634 Рік тому

    Yours video on left and nest docs on right make my night, Wow

  • @clernis1861
    @clernis1861 Рік тому

    Great tutorial, thanks to you i saved a lot of time, without this video i wouldn't be able to finish task that i was signed to. I can’t thank you enough.

  • @chijiokeokwuosa4851
    @chijiokeokwuosa4851 2 роки тому +1

    Thanks so much for your videos on nest js. I got a new job that requires that i work with Nest Js and your videos have been helpful

    • @mariusespejo
      @mariusespejo  2 роки тому +2

      Glad to hear that man, congratulations on the new job!

  • @josephandrade287
    @josephandrade287 Рік тому

    dude, you are legit. thank you so much

  • @kushalsb460
    @kushalsb460 9 місяців тому

    great content.. even useful after 2 years. thanks a lot.

  • @mysteriousmsn
    @mysteriousmsn Рік тому

    Awesome tutorials which covers all the fundamentals to get involve in the typeORM project

  • @rajgohil8610
    @rajgohil8610 2 роки тому +2

    Another excellent explanation video...many thanks for sharing your knowledge...you always go above and above and go extremely deep into educating us. I pray that God bless you and that your channel continues to develop at a rapid pace.

  • @muhammedsinan3897
    @muhammedsinan3897 Рік тому

    thank you ..man..it is one of the most beautiful tutorials I ever watched.

  • @darknight9185
    @darknight9185 Рік тому

    thanks for creating such good tutorial

  • @MaybeBL1TZ
    @MaybeBL1TZ 2 роки тому +1

    at this point we need a fully nest api even if the video is 4 hours long the way you teach and explain stuff is just amazing i can't get bored ✌🏻❤️

    • @mariusespejo
      @mariusespejo  2 роки тому +1

      Thank you 🙏 definitely a full API project build with all the core concepts put together I think would make an awesome video but it will take some time, will consider it

    • @MaybeBL1TZ
      @MaybeBL1TZ 2 роки тому

      @@mariusespejo no problem take all your time and am sure you'll make amazing content

    • @juanvibeats3880
      @juanvibeats3880 2 роки тому

      @@mariusespejo Hey Marius, do you provide tutoring services by any chance? I'd love to learn directly from you! Please let me know if you'd consider it!

    • @mariusespejo
      @mariusespejo  2 роки тому

      Not at the moment, although I’ll definitely consider it and look into it. What sorts of things would you want to learn from me directly?

  • @Dima_Elagin
    @Dima_Elagin 9 місяців тому

    Thanks man. That's a great tutorial

  • @DO462
    @DO462 3 роки тому +1

    You just can't imagine how helpfull this was. Liked and subscribed!

  • @smartcoder6586
    @smartcoder6586 Рік тому

    Well explained. Thankyou Very much.

  • @ivelinstoyanov4229
    @ivelinstoyanov4229 3 роки тому +10

    That's probably the first comment I'm leaving on a youtube video in years but I just wanted to say that you're amazing! Just finished your nestjs graphql video and I don't know what it is about your tutorials but I feel like they're hands down one of the best in the programming field. Thank you again! :)
    PS: Would love to see more NestJS GraphQL videos ^^

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      Thanks Ivelin! I appreciate that! 🙏
      Definitely more graphql content in the future!

  • @udev6707
    @udev6707 3 роки тому +5

    You deserve millions of subscribers man🙂

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      haha thank you, hope you’re one of them!

  • @michaelantoni8323
    @michaelantoni8323 2 роки тому

    Thank you for this TypeOrm Tutorial

  • @raymondyoo5461
    @raymondyoo5461 2 роки тому

    It was a greate introduction to TypeORM relations.
    Thanks a lot 👍👍

  • @nagarjunapradeepkumar802
    @nagarjunapradeepkumar802 3 роки тому

    best ever tutorial, so easy to understand

  • @mirkahromi
    @mirkahromi 2 роки тому

    well-structured and well-designed tutorials.

  • @HenBarLevi
    @HenBarLevi Рік тому

    awesome explanation thank you

  • @res3064
    @res3064 3 роки тому +1

    You always help me with your videos. Thank you man, keep up great content as always ❤️

  • @airplaneCrashe
    @airplaneCrashe Рік тому

    Good tutorial. thanks

  • @sjnprjl
    @sjnprjl 2 роки тому

    You are awesome, man!!!!

  • @ganjargingintahyudin9774
    @ganjargingintahyudin9774 2 роки тому

    Oh man.. thanks for this tutorial

  • @ceciliaserafini
    @ceciliaserafini 3 роки тому

    Hello Marius, Oh! I am very grateful for all the videos about TypeORM and NestJS, so helpfull. Thank you very much for sharing this knowledge in a didactic and clear way, you are the best! ❤

    • @mariusespejo
      @mariusespejo  3 роки тому

      Hi Ceci! I’m glad you’re finding the channel useful, thanks for your feedback 🙏

  • @SameeraSenarathna
    @SameeraSenarathna 3 роки тому

    Extremely useful. Thank you Marius.

  • @mehinhuseynova1426
    @mehinhuseynova1426 3 роки тому

    Awesome, every single detail is well explained.

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      glad it’s not confusing, thanks for your feedback 😄

  • @P4trickSensei
    @P4trickSensei 2 роки тому

    Very well put together. Thank you!

  • @innocentmazando3808
    @innocentmazando3808 Рік тому

    Thanks a lot @Marius. Youe tutorials are making my NestJS journey so easy.
    Keep up the good work sir :)

    • @mariusespejo
      @mariusespejo  Рік тому

      Happy to hear that, thanks for the comment!

  • @pratiknaik261
    @pratiknaik261 2 роки тому

    Amazing explanation on the stuff,Nicely done!!

  • @BigBahss
    @BigBahss Рік тому

    AMAZING tutorial. You've definitely earned a sub, and I'll be checking out your other tutorials

  • @yunusemreince3692
    @yunusemreince3692 2 роки тому

    Hi Marius,
    I just found your channel with this video. I really appreciate the way you explain the things in simple.
    Thanks a lot 👍

    • @mariusespejo
      @mariusespejo  2 роки тому

      Glad you’re finding the content useful!

  • @mostafaelgazar8512
    @mostafaelgazar8512 2 роки тому

    you are doing great ,thanks

  • @hwangmg5581
    @hwangmg5581 2 роки тому

    This is what i finally need it 🙌 thanks 😊

  • @mastercode7851
    @mastercode7851 3 роки тому

    thanks a lot this was the best explanation ever

  • @artleitch
    @artleitch 2 роки тому +1

    Thanks for this video. Really well paced, everything is well explained, incredibly helpful. Subscribed and looking forward to more videos :)

  • @thongtech1984
    @thongtech1984 2 роки тому

    absolutely beautiful vid

  • @javierpons50
    @javierpons50 2 роки тому

    Excellent video thank you!

  • @yuriiboiko679
    @yuriiboiko679 2 роки тому

    Thanks a lot - useful tuttorial for people who modef from another language into nodejs (nestJs)

  • @hanzheng173
    @hanzheng173 3 роки тому

    Very appreciate for this amazing video. Keep going!

  • @bartoszpierdolny6978
    @bartoszpierdolny6978 3 роки тому

    I feel like a girl in a fashion boutique on your channel, the only difference is that she don't have enough money to buy everything and I don't have enough time to watch, like and comment every video :D

  • @YourMom-rg5jk
    @YourMom-rg5jk 3 роки тому

    Incredible, thank you so much! Subscribed.

  • @leekimah
    @leekimah 2 роки тому

    Thank you sir! This helped.

  • @MartinPerez-mi1ty
    @MartinPerez-mi1ty 3 роки тому

    So helpful, i really enjoy your videos, greetings from Peru, keep it up!

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      awesome to know I'm reaching Peru! thank you!

  • @ayoubbenbrahim1891
    @ayoubbenbrahim1891 2 роки тому

    Thank you man i find this soo helpful keep the good work

  • @rohitdasu
    @rohitdasu 3 роки тому

    Excellent! Thanks

  • @vasilevictordurlesteanu2435

    God bless you Marius

  • @ahoussimea7164
    @ahoussimea7164 2 роки тому

    Great one. Keep it up

  • @bcdbcdyedek
    @bcdbcdyedek Рік тому

    Amazing content!! It really helps a lot ! Keep it up

  • @peroforrr7663
    @peroforrr7663 2 роки тому

    You really help me thank you so much

  • @user-dw8lb8lc7u
    @user-dw8lb8lc7u 3 роки тому

    very usefull, thanks for videos!

  • @kurtestacion6113
    @kurtestacion6113 3 роки тому

    Appreciate this man! Keep it up! ❤

  • @Varuag89b
    @Varuag89b 3 роки тому

    Great content Marius👍, as always :)

  • @reisap1
    @reisap1 3 роки тому

    thanks for this video..this help me a alot...you are awesome.

  • @sasg87962
    @sasg87962 2 роки тому

    remind me of symfony and doctrine ❤❤❤❤

  • @deepakpadliya2714
    @deepakpadliya2714 2 роки тому

    HI Marius Espejo,
    Thanks for the Grate explanation
    1. Can you give an example for Many to Many relationship like user and Friends.
    2. Can you give an example of find with many to many relationship with where clause

    • @mariusespejo
      @mariusespejo  2 роки тому

      Did you watch the entire video? I thought I did cover Many to Many

  • @vannakdy4974
    @vannakdy4974 Рік тому

    Thank so much

  • @berenjor
    @berenjor 4 місяці тому

    Greta tutorial! Also, what is the markdown editor you're using throughout the video? It looks great

    • @mariusespejo
      @mariusespejo  4 місяці тому +1

      That’s the bear app, if you want something clean and simple it’s great. But nowadays I’d probably use Obsidian

  • @programmingwithnit5308
    @programmingwithnit5308 Рік тому

    Thank you so much

  • @stylesg7818
    @stylesg7818 3 роки тому

    Thanks again.

  • @theshroomlife
    @theshroomlife 2 роки тому

    thank you!

  • @maximus4510
    @maximus4510 3 роки тому +1

    41:27 shows a raw query in the terminal, are you using a special extension for that?

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      notice at 2:43 that you can configure logging in the connection options

    • @maximus4510
      @maximus4510 3 роки тому

      @@mariusespejo this is AWESOME thank you!!

    • @mariusespejo
      @mariusespejo  3 роки тому

      no problem!

  • @frankli7035
    @frankli7035 3 роки тому +1

    Hi man, this is amazing. Could you share more deeper like how to define the relationship inside the entities service and resolvers rather than seeding the data into the database?

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      That’s exactly what I did in this video. I did show a method named seed but the point was to show how you’d do inserts in the service.. To make that more real you’d instead have some kind of create method which accepts a DTO to have the data as input and perform the same exact operations to insert and relate

    • @frankli7035
      @frankli7035 3 роки тому

      @@mariusespejo Thanks for the response, really helpful, I'll try this later, really appreciate it...... great channel, has referred to all my friends...

    • @frankli7035
      @frankli7035 3 роки тому

      @@mariusespejo hi man,any way to reach out to you? Discord or email?

    • @frankli7035
      @frankli7035 3 роки тому

      @@mariusespejo , I kind of get what's your point, but the problem is how to implement with the input and the service, like what should I defined in the tasks.input to get the right employee id as the foreign key,and in the service do I need to inject all the related Repositories or just it's self's Repository? Maybe for you just a one minute set up but for a rookie like me can't find it anywhere ,so pls help to make a simple guide? Tks,really appreciate

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      Have you seen the typeorm fundamentals vid in my channel? Might help

  • @scottgasparick3753
    @scottgasparick3753 2 роки тому

    First off, all of your NestJS and TypeORM are top-notch. Great pacing and flow. Many times you will expand the details in regards to a particular method or decorator (such as at 19:19 when explaining the @JoinTable options). How are you pulling that up?

    • @mariusespejo
      @mariusespejo  2 роки тому

      Thanks Scott, I appreciate your feedback! Regarding your question, that is a feature in most editors/IDEs for typed languages, where you can do (on mac) CMD + Click to “drill into” the underlying type or definition.. on windows I think it’s CTRL + Click

  • @hongsonnguyen9620
    @hongsonnguyen9620 6 місяців тому

    Nice

  • @prasadbaraskar2569
    @prasadbaraskar2569 2 роки тому

    It was a very helpful tutorial. Thank you. Can you please explain how we can use update query for relational table.

    • @mariusespejo
      @mariusespejo  2 роки тому +1

      There’s another typeorm fundamentals video in my channel that I would recommend watching, this is sort of part 2 to that covering relations specifically

  • @yaktd5704
    @yaktd5704 3 роки тому +1

    Thanks man! Sadly NestJS doesn't have a strong community as Expressjs.

    • @mariusespejo
      @mariusespejo  3 роки тому

      well it uses Express under the hood by default so you could argue that it’s utilizing that same community and ecosystem 😄

  • @SpiderMan-wk4gk
    @SpiderMan-wk4gk 2 роки тому

    i hope you upload video for tutorial ORM ManyToMany, OneToMany, ManyToOne... with Api and CRUD this problem. Thank so much !!!

    • @mariusespejo
      @mariusespejo  2 роки тому

      isn’t that pretty much what this video was? What’s important to takeaway from this is how to do represent and query those relations. Which you can use in services, which you can then use in controllers to fully build out your API end to end

  • @ms0615122
    @ms0615122 3 роки тому

    Thank you

  • @ashishkumari-yg4gn
    @ashishkumari-yg4gn Рік тому

    TypeError: Cannot read properties of undefined (reading '_id')
    The meeting is getting saved but still this error is coming and further which the code is not working ( manager is not getting saved)
    I

  • @joraz8575
    @joraz8575 Рік тому

    Good tutorial and great thanks !Can you please make a tutorial for html to pdf using templating ejs in Nestjs ?

  • @pareshmaniyar8273
    @pareshmaniyar8273 2 роки тому +1

    Hey, I have started building an app for School, where there are two tables, teachers and students.
    There is a contactInfo table I want to use in both of them. So I placed a contactInfo id at teachers and students.
    How to have a one to one relation with contact info and teachers as well as students table? Also cascading should work

    • @mariusespejo
      @mariusespejo  2 роки тому

      I covered one-to-one, did you watch the whole thing? Or was it not clear?

  • @emmanuelaustine680
    @emmanuelaustine680 3 роки тому

    thanks marius

  • @quangle3515
    @quangle3515 Рік тому

    which is auto snippet code you are using? Thank

  • @vzlomer1000
    @vzlomer1000 4 місяці тому

    thnks

  • @AfifAlfiano
    @AfifAlfiano 3 роки тому

    Thankss

  • @chans9055
    @chans9055 Рік тому

    Thank you for the great tutorial Marius. I was playing with the code you wrote on the tutorial and I wonder if it's also possible to limit the number of tasks when you select employee by id? for example if the employee has too many tasks and don't need to show all of them but few of the latest ones. Is it possible to achieve this? or am I trying to do something impossible?

    • @mariusespejo
      @mariusespejo  Рік тому +1

      If I understand what you’re asking, of simply limiting the number of results, yes most relational DBs support adding a limit. For example you can query sorted by a date column (latest) and only limit to the first few results

  • @ekkirizkiramadhan3553
    @ekkirizkiramadhan3553 2 роки тому

    can we have 2 or 4 relationship? how to recreated it? thx

  • @christianangelomsulit3759
    @christianangelomsulit3759 3 роки тому

    Size limitation for directReports? what is the best way to query that property when a manager has 100+ employees?

    • @mariusespejo
      @mariusespejo  3 роки тому +1

      you can implement a form of pagination
      and/or perhaps use a separate direct api call for it like
      /employees?manager=managerId&limit=10
      typeorm has support for querying with limit/take and offset

  • @SameerG2387
    @SameerG2387 2 роки тому

    Well explained @marius. Just have a question on the lazy load case. I prefer lazy load for the fact that I can choose what relations are required for me at the service layer, instead of defining all the relations with find at the Data Layer. Using lazy load I can fetch data at my service layer when and where required. Will like to have your thoughts on this use case.

    • @mariusespejo
      @mariusespejo  2 роки тому

      Yup, I don’t think either way is better, it’s really all preference

    • @SameerG2387
      @SameerG2387 2 роки тому

      @@mariusespejo Agree Thanks for replying back.

  • @muratasarslan2359
    @muratasarslan2359 3 роки тому +1

    Very helpful, thank you :-)
    I saw different code samples about CRUD operations with TypeORM. Some uses Repositories, some not. Such as;
    const userRepo = getConnection("defalt").getRepository(User);
    const user = await userRepo
    .create({
    email,
    firstName,
    lastName,
    password: hashedPassword,
    })
    .save();
    and without repository;
    const user = await User.create({
    email,
    firstName,
    lastName,
    password: hashedPassword,
    }).save();
    they do the same job. When or why to use repository?
    Thanks

    • @mariusespejo
      @mariusespejo  2 роки тому +1

      I would suggest reading about Active Record vs Data Mapper patterns, there are pros and cons to both and it’s ultimately up to your preference. In nestjs specifically it will work best with the repositories

  • @yadimansinurat3674
    @yadimansinurat3674 2 роки тому

    i always get this :
    [Nest] 6684 - 11/16/2021, 11:51:29 ERROR [ExceptionHandler] Nest can't resolve dependencies of the AppService (?, ContactInfoRepository, MeetingRepository, TaskRepository). Please make sure that the argument EmployeeRepository at index [0] is available in the AppModule context.
    please help me : (

    • @mariusespejo
      @mariusespejo  2 роки тому

      If it can’t inject the repository that means you like didn’t do TypeormModule.forFeature for that employee entity

  • @thetaks9404
    @thetaks9404 6 місяців тому

    can you please help, one to one cascade delete doesn't work typeorm? because I tried all the methods, after searching on the Internet I saw that many people encountered this problem

    • @mariusespejo
      @mariusespejo  6 місяців тому

      Cascade deletion is database responsibility not your ORM’s. Make sure you actually have the foreign key in place with Cascade delete setting on your column schema. Then you delete from the referencing side.

  • @igbokwelaurence5882
    @igbokwelaurence5882 3 роки тому

    Hi Marius, your videos have been super helpful. I have a scenario where a User has many assessments, and one assessment has many questions, each lye on seperate tables, how can i join so when i query a user, I see all his assessments and the questions for each of those assessment

    • @mariusespejo
      @mariusespejo  3 роки тому

      Using the .find() api will let you do nested/sub relations, you can try something like: this.usersRepository.find( { relations: [ ‘assessments’, ‘assessments.questions’ ] } );

    • @mariusespejo
      @mariusespejo  3 роки тому

      Or just use the query builder which should let you do basically anything you can normally do with sql, meaning using multiple joins to achieve the same result, that should be also covered in this video I believe

  • @jhumerapus1881
    @jhumerapus1881 2 роки тому

    why is there no employeeId on task? it was on ER diagram

  • @igorigor806
    @igorigor806 2 роки тому

    Hi, thanks for the video! I have a question about skip and take for the “children” of the relations, so basically pagination. Is it possible to set limit and offset for (for example) the tasks of an employee during the DB query or I should do it programmatically after I get everything from the DB?

    • @mariusespejo
      @mariusespejo  2 роки тому

      You have to think about it from a SQL perspective, if you can write a sql query with limit and offset then you likely can also do it from typeorm. Although probably not with pulling relations with the find() API you’ll likely want to do your example using the query builder, do a join, and set the limit and offset there

  • @fernandomartinez4304
    @fernandomartinez4304 2 роки тому

    Hi Marius, thanks for ur content. I have a question, if the user is in fact a manager, he needs to set manager field to null, right? We put manager field @ManytoOne(...{..., nullable:true}) ???

    • @mariusespejo
      @mariusespejo  2 роки тому

      Yeah generally one way to represent a parent in a parent/child relationship is to set the the parent’s field as null. However in an employee database I would imagine everyone except the CEO would have a manager

  • @nilokillian
    @nilokillian 3 роки тому

    Was looking for TypeORM stuff and come across your channel. It's quite good actually . Hit subscribe btn

  • @ashishkumari-yg4gn
    @ashishkumari-yg4gn Рік тому

    Thank you sir for the video.
    Please make a video of relations with TypeORM mongodb as many to many bi-directional relation is giving error - TypeError: Cannot read properties of undefined (reading '_id')
    The meeting is getting saved but still this error is coming and further which the code is not working ( manager is not getting saved)

  • @luqmanusman70
    @luqmanusman70 5 місяців тому

    hi, is it possible to create a single view for join query instead of multiple data subsets. Say I need a customer name from customer table with every order, my order data should be look like this:
    {
    order: 1
    orderdate: 2023-04-20
    customername: abc
    }
    not like showing
    customer[] as a separate object.
    Please advise.

    • @mariusespejo
      @mariusespejo  5 місяців тому

      Are you asking if typeorm supports views? Yes you can create view entities and query them like normal tables
      typeorm.io/view-entities

    • @luqmanusman70
      @luqmanusman70 5 місяців тому

      @@mariusespejo Yes bro, I exactly needed the same option, thanks a lot and take care.

  • @debostrazza3928
    @debostrazza3928 Рік тому

    @mariusespejo I love this video, I saw it every time I need help. But this time I have a question: I have two entities whit manyToMany relationship and I did a queryBuilder to filter the info by an input. The thing is that I have a leftJoinAndSelect and then in a where clause I have a sentence whit LIKE operator. How can I do to filter a property to the entity that is given whit the relationship? (I don't know if it's understanding)

    • @mariusespejo
      @mariusespejo  Рік тому

      If I understand, you’re trying to filter based on a value on the related table? e.g. let’s say you have entities Photo and User with a many to many relationship. You want to find all the users tagged on a photo, where there name starts with “Mar” for example. Then you might have a query like this, using query builder. Basically make sure you’re utilizing the alias that you create with your join
      this.photosRepository.createQueryBuilder(“photo”).leftJoinAndSelect(“photo.users”, “user”).where(“user.name LIKE :name”, { name: “Mar%” }).getMany();

  • @LemarinelNet
    @LemarinelNet 2 роки тому

    Hey, I'm trying to dive into NestJS with TypeORM, but coming from Laravel, I'm having a hard time using data mappers instead of active record pattern...
    Would you make a tutorial for NestJS with TypeORM using activeRecord pattern (or even Sequelize ?)
    Thanks anyway !

    • @mariusespejo
      @mariusespejo  2 роки тому

      The typeorm integration with nest specifically uses the data mapper with repositories. That’s because entities aren’t “injectable” they’re just representing the data. It’s not really that big of a shift, you simply instead either use services or custom repositories for your query methods

  • @vithusas4024
    @vithusas4024 3 роки тому

    Is it possible to use NestJS without type orm with mysql? What if I want to write plain sql statements instead of type orm? you can do a video using only sql statements?

    • @mariusespejo
      @mariusespejo  3 роки тому

      I’m sure you can but it’s not very practical to use the mysql driver directly like that. Typeorm can also do raw queries if you really wanted to. Or you can use knexjs