Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PouchDB compatibility #19

Closed
robobit opened this issue Jan 14, 2016 · 5 comments
Closed

PouchDB compatibility #19

robobit opened this issue Jan 14, 2016 · 5 comments
Labels

Comments

@robobit
Copy link

robobit commented Jan 14, 2016

I'm trying to make this work with PouchDB. So far I made a couple of fixes to PouchDB, specifically to pass the encryption key in. Also pouch caches database objects on their name only, changed this to use the full options, ie. also the encryption key.
Now a have basic operation with pouch and sqlcipher working (can put and get objects), however queries fail (both temporary and persistent). Any ideas how to make this work or hints how to fix it?

@brodycj
Copy link
Collaborator

brodycj commented Jan 15, 2016

Unfortunately I am not so experienced with running PouchDB and cannot promise when I will have a chance to look at this issue.

@robobit
Copy link
Author

robobit commented Jan 15, 2016

Thanks for your quick response. I'm still investigating the issue, it doesn't seem to be sqlcipher specific, I get the same problem when using the normal sqlite plugin.

In my log I get this error:

Error in Success callbackId: SQLitePlugin238116064 : TypeError: undefined is not an object (evaluating 'r.type')

Which occurs in the mycb callback in SQLitePlugin.js (~ line 407).

@brodycj
Copy link
Collaborator

brodycj commented Jan 15, 2016

I think this is caused by the problem reported in storesafe/cordova-sqlite-storage/issues/409. A quick fix is to edit www/SQLitePlugin.js as follows:

$ git diff -U7 www
diff --git a/www/SQLitePlugin.js b/www/SQLitePlugin.js
index c9e2c88..e0a00b8 100644
--- a/www/SQLitePlugin.js
+++ b/www/SQLitePlugin.js
@@ -118,15 +118,15 @@
   };

   SQLitePlugin.prototype.readTransaction = function(fn, error, success) {
     if (!this.openDBs[this.dbname]) {
       error(newSQLError('database not open'));
       return;
     }
-    this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, false, true));
+    this.addTransaction(new SQLitePluginTransaction(this, fn, error, success, true, true));
   };

   SQLitePlugin.prototype.startNextTransaction = function() {
     var self;
     self = this;
     nextTick((function(_this) {
       return function() {

@robobit
Copy link
Author

robobit commented Jan 15, 2016

I can confirm that this indeed fixes the issue.

Thank you so much!

brodycj pushed a commit to cbforks/cordova-sqlcipher-adapter-dev that referenced this issue Feb 12, 2016
@brodycj
Copy link
Collaborator

brodycj commented Feb 12, 2016

A workaround fix is now integrated and covered by the test suite.

@brodycj brodycj closed this as completed Feb 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants