N
N
Nikita2014-11-26 17:44:56
MongoDB
Nikita, 2014-11-26 17:44:56

How to implement news feed in node.js?

Available:
*User
*User's friends
*The ability to add some object with small data to your account
*The ability to change and delete these objects
The user has a news feed where these friends objects are displayed, sorted by publication date.
Please share your experience and approach to the implementation of such a news feed.
Approximate audience of the project: several thousand users.
PS Server part for mob. applications, has its own separate server.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lega, 2014-11-26
@cancel0

For example, you can do this, the structure of the news and the user:

news = {
  content: '',
  when: <datetime>,
  author_id: <objectid>
}
user = {
  name: '',
  friends: [<objectid>, <objectid>]
}

Index: db.news.ensureIndex({ when: -1, author_id: 1}) // when comes first because author_id will participate in multi-query
Fetch: db.news.find({ author_id:{ $in:user.friends }}).sort({ when: -1 })

S
Sergey, 2014-11-26
Protko @Fesor

Just like a blog.

A
Artem, 2014-11-26
@mrRontgen

Change models here ( news, add users). Once for mobile applications, I would make RESTful routes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question