Created
January 3, 2013 15:30
-
-
Save calvinmetcalf/4444296 to your computer and use it in GitHub Desktop.
connect to a CouchDB that syncs locally to indexDB if available, if not tries webSQL, finally just follow the CouchDB directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function pouchSync(dbURL,cb){ | |
| var dbName = dbURL.split("/").pop(); | |
| Pouch(dbName,function(err1,db1){ | |
| Pouch(dbUrl,function(err2,db2){ | |
| if (db1 && db2){ | |
| db1.replicate.from(db2,{continuous:true}); | |
| db1.replicate.to(db2,{continuous:true}); | |
| cb(null, db1); | |
| }else if (db2){ | |
| cb(null, db2); | |
| }else{ | |
| cb(true); | |
| } | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment