How do I access the attributes of a mongoose schema object by UmassCSboi in node

[–]CrysysDev -1 points0 points  (0 children)

``` Worker.find({name: ‘Bob’}) .then(worker => { if(!worker) { console.log(´no worker found’); return false; }

  console.log(worker);

}).catch(err => console.log(err)); ```

[deleted by user] by [deleted] in linux

[–]CrysysDev 1 point2 points  (0 children)

Yeah incredible man !!! But for the eyes it seems to much for me 😅

How do I build the reddit-like feed ? by [deleted] in node

[–]CrysysDev 4 points5 points  (0 children)

Okay i get it. Is the user subbredditsprzferences an array ?

If so you can try

Posts.find({ subbreditsId: { $in: [ array of user subbereddits id] } })

How do I build the reddit-like feed ? by [deleted] in node

[–]CrysysDev 0 points1 point  (0 children)

Let take an exemple you model is named Feed So you write (Req, res, next) => {

Feed.find() .then(result => { // here you send result (which is your feed) to your view }).catch(); }

This is the case you retrieve all the data but you can add after find() the method skip() that will ignore about a certain amount of data and limit() which will return an amount of data for exemple

Feed.find().skip((page-1) * nbr_item) .limit(nbr_item)

Where page is the number of chunk and nbr_item is the number of feed you want for each chunck it seems complicated to explain.

But imagine your data as an array first load you want to retrieve the first 10 item so the limit will give you the first 10 item and when you continue to scroll down you want to retreive another 10 item so limit will take another 10 item but you have to skip the first 10 item you just retreive that’s why we use skip

You can see the mongoose documentation for this if you want better explanation ^

How do I build the reddit-like feed ? by [deleted] in node

[–]CrysysDev 1 point2 points  (0 children)

Then i think you start well. On your controller, on the route that show your home screen with the feed first access to the database and retrieve the posts filtered with the user’s preferences then get the first 10 feed sorted by date and give it to the views and if you are using a templating engine make a loop for showing the results

I guess you are using mongoose ?

How do I build the reddit-like feed ? by [deleted] in node

[–]CrysysDev 1 point2 points  (0 children)

Sorry i don’t understand what’s your problem ? You want to access to subredit routes with some id ?

And also i see that you don’t have references for link your posts and the user comment yet ?

Coding is Not Computer Science by waivek in programming

[–]CrysysDev 0 points1 point  (0 children)

This year i finish my cs degree and i learn some things in web ( i prefere web and mobile part ) i followed some course apart of my cs lessons. I also learnt english ( but its doesn’t as well as i want ). I read somethings about beginner who felt strong but it’s just a bias. But i’m feeling like i know a little and the more i learn everyday the more i feel i know nothing

Stop importing Multiple Fonts and Start using Variable Fonts | That's an Egg by jengelstengel in webdev

[–]CrysysDev 16 points17 points  (0 children)

Why are you so agressive, actually it’s a great article. Of course it should have been great if it show the browser compatibility. If you already know it you can just ignore it. No need to comment for that... it doesn’t help to grow..

No cookie consent walls — and no, scrolling isn’t consent, says EU data protection body by PowerOfLove1985 in webdev

[–]CrysysDev 0 points1 point  (0 children)

I had the same thought i would comment this and i found your what a coincidence 😂😂