Ensured that if the paginatedField's value is null or undefined, it gets properly transferred via the paging handles next and previous.
If sorting case-insensitively, replace those with the empty string for comparing, as mongodb's $toLower transforms both null and undefined into it.
If sorting case-sensitively, handle each of the cases, taking into account that undefined sorts before null and null before everything else.
Change the README to instruct users to avoid mixing types (before it was avoiding emtpy values).
Updated bson and mongoist even though it was not necessary for this ticket.
Potential Risks
It is unclear whether the conditions used to check for undefined and null (or non-undefined, non-null, and combinations) will use indices efficiently. But this only happens in the specific case where this change kicks in: it will not alter the performance of existing correct code.
Test Plan
See unit tests.
Checklist
[x] I've increased test coverage
[x] Since this is a public repository, I've checked I'm not publishing private data in the code, commit comments, or this PR.
Changes Made
paginatedField
's value isnull
orundefined
, it gets properly transferred via the paging handlesnext
andprevious
.$toLower
transforms bothnull
andundefined
into it.undefined
sorts beforenull
andnull
before everything else.bson
andmongoist
even though it was not necessary for this ticket.Potential Risks
It is unclear whether the conditions used to check for
undefined
andnull
(or non-undefined, non-null, and combinations) will use indices efficiently. But this only happens in the specific case where this change kicks in: it will not alter the performance of existing correct code.Test Plan
See unit tests.
Checklist