Categories
In mongodb, is it possible to sort by part of a field (string)?
The database contains the strings "yyyy-mm-dd hh:ii:ss", you need to sort by part of the string "yyyy-mm-dd". Can I somehow use the substr operator in sorting?
Answer the question
In order to leave comments, you need to log in
db.collection.find(query).toArray.sort(customSortFunction)
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question