AM Coder - MongooseJS Course #4 - Mongoose Relationships (ObjectID and Populate)

  Рет қаралды 8,519

Web Development with Alex Merced

Web Development with Alex Merced

2 жыл бұрын

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
@lyda1283 Ай бұрын
Been searchinig everywhere for how to fech the nested objectId, your video explained it perfectly. Thank you
@santiagotesta9720
@santiagotesta9720 Жыл бұрын
Great tuto! Quite clear and simple. Good job :D
@josephuzuegbu7431
@josephuzuegbu7431 Жыл бұрын
You really explained populate very well
@CristianIntriago_
@CristianIntriago_ Ай бұрын
Thank you, finally understood populate LOL
@scienceblossom6197
@scienceblossom6197 Жыл бұрын
Amazing tutorial, thanks a lot!!!
@fixesdev
@fixesdev Жыл бұрын
Thank you man! great video
@jaybarls
@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
@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
@mmmdtagliyev4176
@mmmdtagliyev4176 5 ай бұрын
Thanks a lot !
@pedrocajas478
@pedrocajas478 2 жыл бұрын
i got a question. what if you want to search the dog by their owner name? how can i get that query?
@AlexMercedCoder
@AlexMercedCoder 2 жыл бұрын
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
@pedrocajas478
@pedrocajas478 2 жыл бұрын
@@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
@AlexMercedCoder
@AlexMercedCoder 2 жыл бұрын
@@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
@AlexMercedCoder
@AlexMercedCoder 2 жыл бұрын
stackoverflow.com/questions/24536648/mongoose-find-in-referenced-document-properties
@pedrocajas478
@pedrocajas478 2 жыл бұрын
@@AlexMercedCoder thank you Alex!
@hamisikandy2687
@hamisikandy2687 Жыл бұрын
how did you customize your terminal kindly
@AlexMercedCoder
@AlexMercedCoder Жыл бұрын
You can use chalk or a library I created called mercedlogger
@AlexMercedCoder
@AlexMercedCoder Жыл бұрын
Also if you just meant the whole prompt that is starship.rs
@augustocastro376
@augustocastro376 Жыл бұрын
Nice
@adeniyitaofik3832
@adeniyitaofik3832 2 ай бұрын
this doesnt work when saving dog while owner has a unique key
@adeniyitaofik3832
@adeniyitaofik3832 2 ай бұрын
any work around for this
MongoDB Schema Design Best Practices
50:39
Joe Karlsson
Рет қаралды 169 М.
That's how money comes into our family
00:14
Mamasoboliha
Рет қаралды 12 МЛН
HOW DID HE WIN? 😱
00:33
Topper Guild
Рет қаралды 49 МЛН
Каха и суп
00:39
К-Media
Рет қаралды 6 МЛН
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 55 МЛН
Mongoose Subdocs and Population
9:57
Parsity
Рет қаралды 32 М.
MongoDB Schema Design Best Practices
9:58
MongoDB
Рет қаралды 151 М.
MongoDB and Mongoose | Creating a REST API with Node.js
36:03
Academind
Рет қаралды 437 М.
Protocol Buffers Crash Course
36:07
Hussein Nasser
Рет қаралды 238 М.
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 167 М.
One to many relation in mongo database
12:20
Hitesh Choudhary
Рет қаралды 62 М.
MongoDB Crash Course - Schemas and Relationships
46:28
The Full Stack Junkie
Рет қаралды 42 М.
Which Database Model to Choose?
24:38
High-Performance Programming
Рет қаралды 47 М.
Cheapest gaming phone? 🤭 #miniphone #smartphone #iphone #fy
0:19
Pockify™
Рет қаралды 4,1 МЛН
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 67 МЛН
1$ vs 500$ ВИРТУАЛЬНАЯ РЕАЛЬНОСТЬ !
23:20
GoldenBurst
Рет қаралды 1,8 МЛН
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,7 МЛН
Я УКРАЛ ТЕЛЕФОН В МИЛАНЕ
9:18
Игорь Линк
Рет қаралды 127 М.