Get the previous and next values of a string in lexicographic order 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 &gt; 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 &lt; 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 &gt; ' + (id-1) + ' AND ' id &lt; ' (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.
Computing the previous and next lexicographic string is the same as subtracting and adding 1 to a number, only your number is encoded in some higher base corresponding to your alphabet. I presume you already know how to add and subtract 1, but if not, there are many online resources explaining that.

You mention UTF-8, which is not quite an ordered alphabet. Yet your SQL interpreter has some specific rules for ordering strings, and is should include an ordering of the actual alphabet (UTF-8 or smaller).