Here’s an example of using the excellent pouchdb-find plugin’s (https://github.com/nolanlawson/pouchdb-find) regex features. I couldn’t really find a good example in the documentation, but looking at the source code we come up with something like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.find({ | |
selector: { | |
_id: {$gte: null}, | |
name: {$regex: ".*ri.*"} | |
}, | |
fields: ['_id', 'debut', 'name', 'series'] | |
}); |
Note that the $regex command cannot be run on an indexed field, so this will be a slow query – apart from the expensive regex operation, all records are being loaded into memory and scanned.
The above example can be run on the pouchdb-find demo site (http://nolanlawson.github.io/pouchdb-find/)