I'm working with a noSQL database and for certain reasons I can't use equality filtering in my queries
e.g
select all from database where id = 10
is NOT allowed
but inequality filtering is allowed
e.g
select all from database where id > 1
My ID's are UNIQUE strings (emails) and I need to use equality filtering so I thought to convert inequality statements to equality statements (e.g where id = 10 could be written as Where id > 9 AND < 11).
If my ids were numbers I would use code such as this to get my key:
function(id)
{
//assuming no id can be 0 and no id can be larger than 2^53-1. This will return the row with id = 10
var result = sendToDatabaseQuery('SELECT * FROM database where id > ' + (id-1) + ' AND ' id < ' (i+1)');
}
With numbers it would be very easy to do this, but with Strings I have found it to be more challenging. If I have an email such as mysuperfakeemail.gmail.com how could I get the previous and next lexicographic string (I am assuming they are mysuperfakeemail.gmail.col and mysuperfakeemail.gmail.con respectively)? Is there an established algorithm for this type of function already? I am writing this on a nodejs server with UTF-8 characters.