0

I spent hours to figure out why I cannot use Mango Query features. In Fauxton I can neither add Mango Indexes, neither run a Mango query. For instance, in NodeJS:

var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-find'));
var db = new PouchDB('http://localhost:5986/books');
db.createIndex({ index: { fields: ['nom'] } })
    .then(console.log)
    .catch(console.log);

=> { error: 'bad_request',
  reason: 'Referer header required.',
  name: 'bad_request',
  status: 400,
  message: 'Referer header required.' }

Any clue welcome! Thanks

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

It looks like this plugin can only perform the search operation on a local PouchDB database, and not translate it to a remote CouchDB query.

You probably want to set up the local db like this: var db = new PouchDB('books') (instead of the url) and then setup replication for your documents as described here in the PouchDB docs. Your index will not be synced however.

An advantage caused by this is that you can always query your database even if the CouchDB server goes down.

Jannis
  • 31
  • 1
  • 2
  • I gave an example using NodeJS and PouchDB but actually the problem is in the CouchDB 2.0 server since I cannot create Mango indexes in Fauxton or with a curl shell command. Is there some setting in the configuration of CouchDB, or compilation of it? I downloaded the "Apache CouchDB.app" for OSX. Should I install CouchDB from source code and compile it? Any clue? – meHealth Swizerland Feb 18 '17 at 06:55