Closed MCubs closed 5 years ago
Method Cursor::one()
is frapper for findOne
, see https://docs.mongodb.com/manual/reference/method/db.collection.findOne/. Due to the manual:
If multiple documents satisfy the query, this method returns the first document according to the natural order which reflects the order of documents on the disk.
So if you need first document from sorted set, use something like ->sort([])->limit(1)->all()->current()
Hello,
How I get one document with use Cursor method ->sort(). Method ->one() don`t using ->sort(), and methot ->current() deprecated.