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:
[couch_httpd_auth]
require_valid_user = false
Maybe for CrossDomain:
[httpd]
bind_address = 0.0.0.0
WWW-Authenticate = x-Basic realm=“administrator”
/// “x-” to not get the login-dialog of the browser
enable_cors = true
[cors]
origins = *
headers = accept,authorization,content-type,origin
methods = GET,PUT,POST,HEAD,DELETE,OPTIONS
credentials = true
[couch_httpd_oauth]
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') {
emit();
}
}},{include_docs:true},function(err,response){
if(err){
deferred.reject(err);
} else {
deferred.resolve(response.rows);
}
});
return deferred.promise;
};