如何在同一属性上查询Dexie查询的多个子句?

发布于 2025-02-12 18:14:31 字数 489 浏览 1 评论 0原文

我有一系列的字符串,它在Dexie中被索引。 我需要编写一个查询,以搜索没有字符串(a)和字符串(b)的行。 我可以在第一个条件下进行,但是对于第二个条件,我不能在 notequal 之后的子句中应用,因为它返回了 collection ,并且在哪里只能在上应用。表对象

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

是否可以在第一个子句中使用第二个,还是可以实现目标的其他方法?

编辑: 其他可能的解决方案,而不是多个条款。

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

I have a array of strings and it is indexed in dexie.
I need to write a query that searches for the rows that don't have a string(a) and has a string(b).
I can do it with 1st condition, but for second condition, I can't apply where clause after notEqual as it returns collection and where can be applied only on table object

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

Is it possible to apply second where clause, or is there any other approach to achieve the goal?

EDIT:
Other possible solutions, not with multiple where clauses.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2025-02-19 18:14:31

你可以这样做

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

You can do this like

db.table.where('key1').notEqual('String(a)').and('key2').notEqual('String(b)').toArray()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文