All language subtitles for 009 Getting Data From The Database_Downloadly.ir_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,040 --> 00:00:03,280 Here we currently returned 2 00:00:03,280 --> 00:00:04,738 at dummy list of comments 3 00:00:04,738 --> 00:00:07,170 and that's of course not the goal. 4 00:00:07,170 --> 00:00:08,750 Let's remove that. 5 00:00:08,750 --> 00:00:11,430 Instead we wanna work with our client 6 00:00:11,430 --> 00:00:15,280 so this client which we got from connecting up here 7 00:00:16,250 --> 00:00:17,860 we wanna work with that. 8 00:00:17,860 --> 00:00:20,660 And in the get case here we also wanna get access 9 00:00:20,660 --> 00:00:22,683 to the database to which we connected. 10 00:00:24,570 --> 00:00:28,290 Like this and then on that database reach out 11 00:00:28,290 --> 00:00:30,700 to the comments collection 12 00:00:30,700 --> 00:00:32,640 so of course the same collection 13 00:00:32,640 --> 00:00:34,333 we are working on here. 14 00:00:35,440 --> 00:00:37,480 Now, instead of calling insert one 15 00:00:37,480 --> 00:00:39,790 we wanna get all the documents in there 16 00:00:39,790 --> 00:00:43,330 and we can do this with help of the find method. 17 00:00:43,330 --> 00:00:46,740 The find method finds us data in a collection 18 00:00:46,740 --> 00:00:49,460 and we can restrict the results 19 00:00:49,460 --> 00:00:51,410 we can narrow down the results 20 00:00:51,410 --> 00:00:53,030 and we can filter results 21 00:00:53,030 --> 00:00:54,810 but if we call find like this 22 00:00:54,810 --> 00:00:56,720 we will fetch all the comments. 23 00:00:56,720 --> 00:00:58,730 And that's the goal here. 24 00:00:58,730 --> 00:01:01,230 In case you wanna learn more about MongoDB, 25 00:01:01,230 --> 00:01:04,069 I strongly recommend my MongoDB course 26 00:01:04,069 --> 00:01:07,000 which is a full course on MongoDB only. 27 00:01:07,000 --> 00:01:09,500 So that might be worth a look then. 28 00:01:09,500 --> 00:01:14,223 Here will keep it basic and just find all documents. 29 00:01:15,190 --> 00:01:19,720 So here we get the documents by awaiting that operation 30 00:01:19,720 --> 00:01:23,260 and to be precise here we wanna call toArray 31 00:01:23,260 --> 00:01:26,870 to get all the documents as an array, 32 00:01:26,870 --> 00:01:30,160 because by default we would not be getting such an array. 33 00:01:30,160 --> 00:01:33,910 We would be getting a cursor with which we have to navigate 34 00:01:33,910 --> 00:01:36,060 through documents manually 35 00:01:36,060 --> 00:01:38,490 and calling toArray simplifies that, 36 00:01:38,490 --> 00:01:40,610 and simply gives us all the entries 37 00:01:40,610 --> 00:01:43,133 in the comments collection as an array. 38 00:01:44,130 --> 00:01:47,820 Actually before doing that I wanna call sort on find 39 00:01:47,820 --> 00:01:49,580 so on the result of find, 40 00:01:49,580 --> 00:01:50,900 I will call sort 41 00:01:51,790 --> 00:01:56,110 because sort allows us to well sort the results 42 00:01:56,110 --> 00:01:59,280 and we do sort by passing an object to sort 43 00:01:59,280 --> 00:02:04,280 where we then specify one of our keys in our documents, 44 00:02:04,810 --> 00:02:09,130 or for example underscore id for the automatically added id 45 00:02:09,130 --> 00:02:11,490 and then minus or plus one 46 00:02:11,490 --> 00:02:15,790 to define if we wanna sort in descending or ascending order. 47 00:02:15,790 --> 00:02:19,820 And I wanna sort the ids in descending order 48 00:02:19,820 --> 00:02:22,590 which we can do by adding underscore id 49 00:02:22,590 --> 00:02:25,460 and setting it to a value of minus one. 50 00:02:25,460 --> 00:02:27,150 This will sort the comments 51 00:02:27,150 --> 00:02:30,070 which we are fetching in descending order 52 00:02:30,070 --> 00:02:33,220 so that the latest comment is the first comment 53 00:02:33,220 --> 00:02:35,840 in this array which we are fetching. 54 00:02:35,840 --> 00:02:37,470 So that's now our documents 55 00:02:37,470 --> 00:02:39,640 which we get as an array 56 00:02:39,640 --> 00:02:42,880 and hence let's now return our documents here 57 00:02:42,880 --> 00:02:44,800 and see what we get. 58 00:02:44,800 --> 00:02:46,110 If we save this 59 00:02:46,960 --> 00:02:49,660 and we go back to our front end 60 00:02:49,660 --> 00:02:53,680 if we open the console there 61 00:02:53,680 --> 00:02:55,860 the developer tools and I hide the comments 62 00:02:55,860 --> 00:02:57,640 and show them again 63 00:02:57,640 --> 00:02:59,070 we are fetching data again 64 00:02:59,070 --> 00:03:03,290 and now I'm getting a warning regarding my key 65 00:03:03,290 --> 00:03:05,140 but we see the comment 66 00:03:05,140 --> 00:03:06,960 so that works. 67 00:03:06,960 --> 00:03:09,220 We are only getting that comment here 68 00:03:09,220 --> 00:03:10,480 that warning I mean, 69 00:03:10,480 --> 00:03:12,990 because if we have a look at the network tab 70 00:03:12,990 --> 00:03:15,370 we see that the comments were are fetching have 71 00:03:15,370 --> 00:03:17,690 the underscore id field 72 00:03:17,690 --> 00:03:22,690 of course because that was auto generated by MongoDB. 73 00:03:23,070 --> 00:03:27,140 But in my front end code here for the comments 74 00:03:27,140 --> 00:03:32,140 in components input comment list 75 00:03:32,630 --> 00:03:36,640 I'm referring to .id without an underscore. 76 00:03:36,640 --> 00:03:39,550 So the simple fix is to add an underscore here 77 00:03:39,550 --> 00:03:41,530 so that we use the correct field 78 00:03:41,530 --> 00:03:44,000 as a key for the list items. 79 00:03:44,000 --> 00:03:45,800 And if we do that and save this 80 00:03:45,800 --> 00:03:47,530 and reload you will see 81 00:03:47,530 --> 00:03:50,050 that will not get any warning anymore 82 00:03:50,050 --> 00:03:53,690 instead our comments do show up correctly here. 83 00:03:53,690 --> 00:03:56,510 Now ,we could of course improve the front end. 84 00:03:56,510 --> 00:03:59,490 We could show a loading spinner once we are fetching. 85 00:03:59,490 --> 00:04:01,320 We could show some feedback 86 00:04:01,320 --> 00:04:03,760 after we submitted our forum, 87 00:04:03,760 --> 00:04:05,320 but again I wanna focus 88 00:04:05,320 --> 00:04:08,390 on next JS Anti API routes here 89 00:04:08,390 --> 00:04:10,030 which is why I only provided 90 00:04:10,030 --> 00:04:12,730 the Dis Basic Front-End for the moment. 91 00:04:12,730 --> 00:04:14,870 But what we can see with all of that 92 00:04:14,870 --> 00:04:18,390 is that working with our API routes works 93 00:04:18,390 --> 00:04:22,140 and that we are able to work with MongoDB in there 94 00:04:22,140 --> 00:04:25,350 so that we are able to connect our API routes 95 00:04:25,350 --> 00:04:29,943 and the code running in there to a real MongoDB database. 7166

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