Using Pouchdb plugins inside Ionic, demo code requested

Hi, i’ve been working with Pouchdb for a demo app for some weeks and its working pretty fine. The websql adapter is very good for performance.

Anyway, my problem now is to include Pouchdb plugins in order to add authentication and GQL features inside Ionic. As you know, Pouchdb uses requirejs to include plugins but it seems that ionic is not compatible with requirejs.

Please, if anybody was able to use plugins, please show me how. I need to use GQL and Authentication plugin.

PouchDB with pouchdb.authentication.min.js works for me.
add the pouchdb.authentication.min.js after pouchdb-3.2.0.min.js in the header of index.html…

   var cdb = new PouchDB('http://your-db-host:5984/_users');
   cdb.login(couchadminuser,couchadminpassword).then(function(result){ ... },
                                                     function(reason){ ... });

CouchDB-Settings required:
require_valid_user = false

Maybe for CrossDomain:

bind_address =
WWW-Authenticate = x-Basic realm=“administrator”
/// “x-” to not get the login-dialog of the browser
enable_cors = true

origins = *
headers = accept,authorization,content-type,origin
credentials = true

use_users_db = true

But at the moment i am figuring out how to get GQL working…
Get the error “Uncaught TypeError: Object.keys called on non-object” if i put pouchdb.gql.js after pouchdb-3.2.0.min.js, and no error if i put it above pouchdb-3.2.0.min.js, but still wasn’t able to get it working…

Added PouchDB.plugin({ gql: GQL }); before i make my new PouchDB’s,
but myDB.gql({select:’*’,where:“user=‘xxx’”},function(err,res) { this callback doesnt fire });

If i get it, i will post it here…

Think it doesnt work. For me this works though:

self.todos = new PouchDB('todos',{adapter:'websql'}); //Chrome
if(!self.todos.adapter) self.todos = new PouchDB('todos'); //if websql not supported

self.getUserTodos = function(user){
  var deferred = $q.defer();

  self.todos.query({map:function(doc,emit){  //emit necessary for selections
    if(doc.user === user || doc.user === 'all') {
     } else {

  return deferred.promise;

same error over here with GQL.

I changed authentication plugin for some other db design.

i will continue trying to get GQL working


what is the behavior without the line PouchDB.plugin?