0

我正在使用 noSQL 数据库,由于某些原因,我无法在查询中使用相等过滤

例如

select all from database where id = 10 

不被允许

但允许不等式过滤

例如

select all from database where id > 1

我的 ID 是唯一的字符串(电子邮件),我需要使用等式过滤,所以我想将不等式语句转换为等式语句(例如 where id = 10 可以写为 Where id > 9 AND < 11)。

如果我的 id 是数字,我会使用这样的代码来获取我的密钥:

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)');

}

使用数字很容易做到这一点,但使用字符串我发现它更具挑战性。如果我有诸如 mysuperfakeemail.gmail.com 之类的电子邮件,我怎么能得到上一个和下一个字典字符串(我假设它们分别是 mysuperfakeemail.gmail.co l和 mysuperfakeemail.gmail.con ?是否已经有针对此类功能的既定算法?我正在使用 UTF-8 字符的 nodejs 服务器上写这个。

4

0 回答 0