【问题标题】:How to have multiple where clause in dexie query on same property?如何在同一属性的 dexie 查询中有多个 where 子句?
【发布时间】:2022-07-12 17:54:12
【问题描述】:

我有一个字符串数组,它在 dexie 中被索引。 我需要编写一个查询来搜索没有字符串(a)并且有字符串(b)的行。 我可以使用第一个条件,但对于第二个条件,我不能在之后应用 where 子句不相等当它返回时收藏并且只能应用于桌子目的

db.table.where(\'array\').notEqual(\'String(a)\').toArray()

是否可以应用第二个 where 子句,或者是否有任何其他方法可以实现目标?

编辑: 其他可能的解决方案,而不是多个 where 子句。

db.table.toCollection(function (e) { 
  return (!e.array.includes(\'String(a)\') && e.array.includes(\'String(b)\')) 
}).toArray()

    标签: javascript indexeddb dexie


    【解决方案1】:

    你可以这样做

    db.table.where('key1').notEqual('String(a)').and('key2').notEqual('String(b)').toArray()
    

    【讨论】:

    • notEqual 不是 ...and 的函数。过滤函数也应该作为 and 的参数给出。
    猜你喜欢
    • 2016-02-27
    • 1970-01-01
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-30
    • 2019-05-08
    • 2021-10-20
    相关资源
    最近更新 更多