apache / apache/pouchdb

pouchdb-find, $or and multiple $regex conditions and nested properties

Open
#8,534 9 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue
using `pouchdb-find` with the selector of `$or` array and multiple `$regex` conditions throws an error in the console. it seems that `$and` and multiple `$regex` works fine since this [commit](https://github.com/pouchdb/pouchdb/commit/0e27e23f4437bce134d0780a543f08a3020fa4de) has been merged.

### Info
- Environment: browser/hybrid app
- Platform: Chrome/iOS/Android
- Adapter: indexeddb
- Server: no server, PouchDB client.

### Reproduce

1. data downloaded and saved in PouchDB.
2. database index created with fields: `from.name` and `type`.
3. by running the code below, the error console which is attached will appear in the console. using `$and` works tho.

```js
db.find({
selector: {
{
$or: [
{"from.name": {$regex: /foo/i}},
{type: {$regex: /bar/i}},
]
}
}
});
```

![image](https://user-images.githubusercontent.com/5070181/180789256-2e9d94c6-5bde-47a2-943f-13a417f8ff95.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.