{"action":"closed","issue":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/6843","repository_url":"https://api.github.com/repos/pouchdb/pouchdb","labels_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/6843/labels{/name}","comments_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/6843/comments","events_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/6843/events","html_url":"https://github.com/pouchdb/pouchdb/issues/6843","id":273758011,"number":6843,"title":"Find Mango query to remote database returns no results","user":{"login":"faizanahemad","id":7088567,"avatar_url":"https://avatars3.githubusercontent.com/u/7088567?v=4","gravatar_id":"","url":"https://api.github.com/users/faizanahemad","html_url":"https://github.com/faizanahemad","followers_url":"https://api.github.com/users/faizanahemad/followers","following_url":"https://api.github.com/users/faizanahemad/following{/other_user}","gists_url":"https://api.github.com/users/faizanahemad/gists{/gist_id}","starred_url":"https://api.github.com/users/faizanahemad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faizanahemad/subscriptions","organizations_url":"https://api.github.com/users/faizanahemad/orgs","repos_url":"https://api.github.com/users/faizanahemad/repos","events_url":"https://api.github.com/users/faizanahemad/events{/privacy}","received_events_url":"https://api.github.com/users/faizanahemad/received_events","type":"User","site_admin":false},"labels":[{"id":764575334,"url":"https://api.github.com/repos/pouchdb/pouchdb/labels/wontfix","name":"wontfix","color":"ffffff","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-14T11:26:25Z","updated_at":"2018-02-15T11:40:04Z","closed_at":"2018-02-15T11:40:04Z","author_association":"NONE","body":"<!--\r\n     Hello! 👋\r\n     Thank you for opening an issue on PouchDB.\r\n     There is also a 3-Minute read, on how to format your issue:\r\n     https://guides.github.com/features/mastering-markdown/\r\n     This template is optional, but it may help us fix your issue faster.\r\n-->\r\n### Issue\r\nWhile using db.find with a remote database and supplying regex for any fields it does not return any result.\r\n\r\n### Info\r\n- Environment: Node.js and chrome browser\r\n- Platform: Chrome\r\n- Adapter: NA\r\n- Server: CouchDB\r\n- PouchDB version: 6.3.4\r\n\r\n### Reproduce\r\n- Setup local CouchDB\r\n- create database in it named `history`\r\n- Insert some entries of the form below. 1 is enough to test.\r\n```json\r\n{\r\n  \"_id\": \"3W46wCqDhELOtCdS\",\r\n  \"href\": \"http://www.geeksforgeeks.org/efficient-search-in-an-array-where-difference-between-adjacent-is-1/\",\r\n  \"title\": \"efficient search in an array where difference between adjacent is 1\"\r\n}\r\n```\r\n- Setup PouchDB with PouchDB find plugin\r\n- Connect to couchDB by using pouchDB in your node script / browser and try doing find query.\r\n```javascript\r\nvar remoteDB = new PouchDB('http://localhost:5984/history')\r\nvar regex=new RegExp(\"difference\", \"i\");\r\n\r\nremoteDB.find({selector:{href: {$regex:regex}}}).then(r=>r.docs).then(console.log)\r\n\r\n// Above will fail with 400 (Bad Request)\r\n\r\nremoteDB.find({selector:{href: {$regex:/difference/i}}}).then(r=>r.docs).then(console.log)\r\n\r\n// Above will fail with 400 (Bad Request)\r\n\r\nremoteDB.find({selector:{href: {$regex:regex.toString()}}}).then(r=>r.docs).then(console.log)\r\n\r\n// Above will not throw 400, but return empty results.\r\n\r\nremoteDB.find({selector:{href: {$regex:\"(?i)difference\"}}}).then(r=>r.docs).then(console.log)\r\n\r\n// above works\r\nremoteDB.find({selector:{href: {$regex:\"difference\"}}}).then(r=>r.docs).then(console.log)\r\n\r\n// also works\r\n```\r\n\r\n### Further Investigation\r\n- On seeing `pouchdb.js` non minified file, that I downloaded. I find that on line 10884 `options.body = JSON.stringify(options.body);` to serialize the request for sending we use `JSON.stringify` which produces `{}` for regexes.\r\n\r\n"}}
{"actor":{"display_login":"stale"}}