S
S
Stanislav2016-04-20 23:31:24
MongoDB
Stanislav, 2016-04-20 23:31:24

How to determine the position, document number in the collection?

I ran into a problem, it is necessary to find out the document number when selecting with a condition and sorting, but I have no idea how to do this. I think it is not advisable to make a query with a selection of all records, is it possible to somehow determine the document number? For example, by its id, the ID itself is certainly known
Or, using aggregate, number the array of records and pull out the desired number? How correct will it be if there are more than 100,000 records in the collection? Can someone come across this and share a more correct and less loaded way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav, 2016-04-21
@ms-dred

Solved the problem, attached to the publication date

db.coll.find({created: {"$lt": "время создания записи"}}).count()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question