diff --git a/README.md b/README.md index 2ead7c33a..663d27560 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,11 @@ print(result?.insertedID ?? "") // prints `.int64(100)` **Async**: ```swift let query: BSONDocument = ["a": 1] -let result = collection.find(query).flatMap { cursor in +// The `sort` option specifies the order in which results are returned +// via the cursor. In this case, `["_id": -1]` indicates that the documents will +// be returned in descending order according to the `_id` field. +let options = FindOptions(sort: ["_id": -1]) +let result = collection.find(query, options: options).flatMap { cursor in cursor.forEach { doc in print(doc) } @@ -147,7 +151,11 @@ let result = collection.find(query).flatMap { cursor in **Sync**: ```swift let query: BSONDocument = ["a": 1] -let documents = try collection.find(query) +// The `sort` option specifies the order in which results are returned +// via the cursor. In this case, `["_id": -1]` indicates that the documents will +// be returned in descending order according to the `_id` field. +let options = FindOptions(sort: ["_id": -1]) +let documents = try collection.find(query, options: options) for d in documents { print(try d.get()) }