* Sets the sort order of the cursor query. * * @param sort - The key or keys set for the sort. * @param direction - The direction of the sorting (1 or -1).
(sort: Sort | string, direction?: SortDirection)
| 414 | * @param direction - The direction of the sorting (1 or -1). |
| 415 | */ |
| 416 | sort(sort: Sort | string, direction?: SortDirection): this { |
| 417 | this.throwIfInitialized(); |
| 418 | if (this.findOptions.tailable) { |
| 419 | throw new MongoTailableCursorError('Tailable cursor does not support sorting'); |
| 420 | } |
| 421 | |
| 422 | this.findOptions.sort = formatSort(sort, direction); |
| 423 | return this; |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * Allows disk use for blocking sort operations exceeding 100MB memory. (MongoDB 3.2 or higher) |