Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed incorrect continuation token when searching with sort
The continuation token was generated based on _mongo.partitionKey. This is correct when _mongo.partitionKey is the only sort field. When there are other sort fields in the query, the sequence of records are influenced by those fields. Continuation token based on only _mongo.partitionKey value does not produce the correct results for next pages. There is a npm package on "cursor based pagination": https://www.npmjs.com/package/mongo-cursor-pagination The library supports one "paginatedField". The ClearlyDefined api supports sort resulting in multiple sort fields. For example: sort on namespace sorts on three fields: ['coordinates.namespace', 'coordinates.name', 'coordinates.revision']. So the library is not sufficient for CD's need. To generate the correct next page, the continuation token needs to record all the values for sort fields. As an extension of existing logic, _mongo.partitionKey will always be included to the sort fields as a tie breaker. Also added logic to generate pagination query based on multiple sort values.
- Loading branch information