Answer the question
In order to leave comments, you need to log in
How to search in MongoDB by indexes?
Good afternoon
When creating a collection, I create an index
await this.db.collection('users').insertOne({
id: id,
user_id: userId,
sent_at: new Date(),
});
await this.db.collection('throttling_pitch_queue').createIndex({
sent_at: Date.now(), // можно ли как-то использовать new Date() для индексов?
});
const user = database
.collection('users')
.find({
sent_at: {
$gt: new Date(new Date().getTime() - 60000),
},
})
.toArray();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question