I
I
IoChto2020-10-14 10:30:24
MongoDB
IoChto, 2020-10-14 10:30:24

How to get entries for the last week in mongo with one specific parameter?

In MongoDB, the users_messages collection contains user messages on the forum, 1 entry per message. The fields of each entry are timestamp, username, is_moderated, message. How to provide the distribution of the number of moderated posts between users in the last week?
in order to get just moderated, you can, but how have they been for the last week? you can also use mongoose
db.users_messages.find( { is_moderated: true }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IoChto, 2020-10-14
@IoChto

db.users_messages.find({
timestamp: {
$gte: new Date(new Date() - 7 * 60 * 60 * 24 * 1000)
}, is_moderated:true
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question