javascript - Get the previous and next values of a string in lexicographic order -
i'm working nosql database , reasons can't use equality filtering in queries
e.g
select database id = 10
is not allowed
but inequality filtering allowed
e.g
select database id > 1
my id's unique strings (emails) , need use equality filtering thought convert inequality statements equality statements (e.g id = 10 written id > 9 , < 11).
if ids numbers use code such key:
function(id) { //assuming no id can 0 , no id can larger 2^53-1. return row id = 10 var result = sendtodatabasequery('select * database id > ' + (id-1) + ' , ' id < ' (i+1)'); }
with numbers easy this, strings have found more challenging. if have email such mysuperfakeemail.gmail.com how previous , next lexicographic string (i assuming mysuperfakeemail.gmail.col , mysuperfakeemail.gmail.con respectively)? there established algorithm type of function already? writing on nodejs server utf-8 characters.
Comments
Post a Comment