Answer the question
In order to leave comments, you need to log in
How to fetch by object method in Mongodb?
I’ll make a reservation right away that I just started studying Mongodb and a number of questions arose about the capabilities of the database.
I can not solve the problem, I would like to know the opinions of experts, is it really possible to solve it at all or not. db.collection.find({_id: ObjectId('str_id')})
I would like something more elegant, like: db.collection.find({'_id.str': 'str_id'})
or db.collection.find({'_id.valueOf()': 'str_id'})
If you really solve the last task, then you could make selections by time without having to store data about the date the record was created in a separate field, for example:
db.collection.find({'_id.getTimestamp().getMonth()': 2}) // выбор по месяцу
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