What an effective way to postpone the publication of posts to realize?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
46 views
Hi.

Collect a small API server in Node, Express, Mongo. The question arose how best to organize the postponed publication?

For example, I create a document Article, and I want him to not immediately used by your app, and then when I indicate.

How best to do it to avoid unnecessary checks, queries, filtering, and so on?

The first thing on your mind is to specify the field PublishAt and there to specify the time, but then the server will have each post check once again before sending it to the client. But if such posts 100 pieces and 1000 visitors? Caching and so on it seems clear, but how to properly implement initially?
by | 46 views

2 Answers

0 like 0 dislike
While fetching from database of published posts adds a condition that selects only the posts where PublishAt less than or equal to the current time.
by
0 like 0 dislike
Select from database only the records that have the attribute "published" (e.g., isPublished = 1).

For delayed publication to use crowns, which will be the right time to put this attribute.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
36,596 users