Learn more at AlexMercedCoder.com Follow on Twitter @alexmercedcoder Join the developer community at devNursery.com Repo where I store recent code from videos: github.com/AlexMercedCoder/sc...
Пікірлер: 22
@lyda1283Ай бұрын
Been searchinig everywhere for how to fech the nested objectId, your video explained it perfectly. Thank you
@santiagotesta9720 Жыл бұрын
Great tuto! Quite clear and simple. Good job :D
@josephuzuegbu7431 Жыл бұрын
You really explained populate very well
@CristianIntriago_Ай бұрын
Thank you, finally understood populate LOL
@scienceblossom6197 Жыл бұрын
Amazing tutorial, thanks a lot!!!
@fixesdev Жыл бұрын
Thank you man! great video
@jaybarls Жыл бұрын
Hey Alex, these tutorials are great! What I'm less sure about is how to deal with populating an array of objectIds. I always end up with an empty array '[ ]', both in my log and the Mongo shell. Your example works because you explicitly set the owner to the owner as a created variable, but populating a collection doesn't seem to work in the same way - any ideas?
@FilipeAugusto361 Жыл бұрын
Create the dog and owner, and then get the dog.yourArray and then push the owner into the array and then you save using dog.save(). You will have a list of objectsId so just populate and you will have it. Hope you understand english is not my first language
@mmmdtagliyev41765 ай бұрын
Thanks a lot !
@pedrocajas4782 жыл бұрын
i got a question. what if you want to search the dog by their owner name? how can i get that query?
@AlexMercedCoder2 жыл бұрын
A couple different approaches you can filter by the id of the owner or search for the owner and populate the dogs on that owner
@pedrocajas4782 жыл бұрын
@@AlexMercedCoder so, there’s no way to search that way? I mean, I’m working on some project that I’ve to implement this type of query. It’s like a sql join query
@AlexMercedCoder2 жыл бұрын
@@pedrocajas478 yes you can, the user would type in the username on the front end the backend would just need to implement the logic for it (joins aren’t really a thing in mongo) So you can can: search the owners name in the owner collection, populate their dogs then send it back or have the Frontend pass the right id based on the name searched and search the right dog basic on the owner id. You could also just search for all dogs and populate the owners then do an array.fine but that wouldn’t scale well