All language subtitles for 006 Modelling Tour Guides_ Child Referencing_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So we embedded users

into tours in the last video,

and also talked about the drawbacks

of that approach in our specific situation.

And so in this video let's actually connect tours

and users not by embedding but instead by a reference.

And so to start, let's actually get rid

of the code we wrote in the last lecture.

Okay, so this one here,

responsible for performing the embedding basically.

And now let's go here to our guides field.

Okay?

So this time in this video,

the idea is that tours and users will always remain

completely separate entities in our database.

Okay?

So all we save on a certain tour document

is the IDs of the users that are the tour guides

for that specific tour.

Then when we query the tour,

we want to automatically get access to the tour guides.

But again, without them being actually

saved on the tour document itself.

And that exactly is referencing.

So just as we talked about by the beginning of this section.

All right?

And so let me now show you

how we can implement referencing using Mongoose.

Okay?

So, here in the guides we will now want to specify an array.

Okay?

So just like we did before with the locations.

And so that then again means

that these will be some sub-documents.

So embedded documents.

All right?

And now the type is going to be

a new type that we never saw before.

And that is mongoose.Schema.objectId.

Okay?

And what this means is that we expect

a type of each of the elements

in the guides array to be a MongoDB ID.

All right?

And here actually it needs to be a capital O,

okay, otherwise it's not gonna work,

and also all of this here needs to be inside of an object,

just like any other schema type definition.

Okay, because that's all this really is.

Okay, so the type is of this MongoDB ID, basically,

and then we also need to now specify the reference.

And this is where the magic happens behind the scenes,

because here, now we say that the reference should be user.

Okay, and so this really is how we establish references

between different data sets in Mongoose.

And for this we actually do not even need

to have the user to be imported into this document.

So we actually had that here, but we don't even need it.

We had that here for the previous lecture,

but we can comment it out,

because what we just did here is still gonna work.

Okay?

So, let's now go ahead and create a new tour,

and actually I'm going to do it just the way we did before.

So let's just go ahead and delete this one.

Where is the ID?

Here we go.

So delete tour.

So we can use our API for that already.

All right, and now we create a new tour.

And so just like before,

all we pass into the guides is an array of the IDs.

All right?

But this time we actually specified

that an object ID is exactly what we expect.

Right?

So, this here is of the type object ID.

But behind the scenes, it's also referenced to the user.

All right?

So, when we now create this tour here,

it will actually only contain these IDs,

and not the user corresponding to the IDs.

So let's take a look at that.

And so yeah, here we go.

So this is exactly the data that we put in.

Just the IDs of the tour guides.

Okay, and that's exactly what we were expecting.

Because for now, all we really have

is the references inside Mongoose.

And we will then take care of actually getting the data

to show up in our output in the next video.

Okay, because we will do that in two different ways.

Let's also take a look here at Compass really quick,

just to see that as well where is that, yeah, here.

So you see object ID actually,

and then of course, the IDs that we passed in.

So just as we expected with tours and users,

still two completely different entities.

And as I said before, in the next video,

we will then take care of actually displaying

the user data in the output,

using a process called populating.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.