Pouch database: include it in the download mechanism

126 views
Skip to first unread message

Danielo Rodríguez

unread,
May 29, 2015, 4:36:00 PM5/29/15
to tiddl...@googlegroups.com
Hello everyone,

As you may know I'm working on a pouchdb sync adapter for TiddlyWiki. For those that does not know about pouchdb it is a database that lives in the browser permanent store that has the ability to sync to a remote database. This is awesome and the best usage for this library is sync it to a remote server.

Anyway I want to give the possibility to save the wiki in a more traditional way. If you want to use your wiki in a different computer or browser without a server as sync point all you have to do is to click save, download the html file and you're ready.

And I want your opinion about the best way of doing this. The way I envision it is as follows :

1. You click the download button.
2.The database is packed into a special tiddler
3. The html file containing that tiddler is downloaded
4. When the wiki is opened the plugin checks if that special tiddler exists. If it does then it unpacks that tiddler and loads it into the browser's database.
5. Should that tiddler be deleted?

I have other doubts about this work flow. Should the plugin look for this tiddler only if the current database is empty or should do it anyway? If revisions are managed properly this can be used to sync different versions of the same wiki without any server at backend.

I really appreciate your point of view. Regards.

Richard Smith

unread,
May 30, 2015, 8:07:00 AM5/30/15
to tiddl...@googlegroups.com
Hi Danielo,

It seems to me like the database tiddler should be deleted - because it will be re-created if the process is repeated, right? And it's useless while the wiki's open.

Do you mean that pouchdb will contain all of the tiddlers, or a separate db of some kind? 

What would happen if you opened the file in a browser that doesn't support pouchdb? 

Will it be complicated to merge the databases later?

Regards,
Richard

Danielo Rodríguez

unread,
May 30, 2015, 12:05:48 PM5/30/15
to tiddl...@googlegroups.com


El sábado, 30 de mayo de 2015, 14:07:00 (UTC+2), Richard Smith escribió:
Hi Danielo,

It seems to me like the database tiddler should be deleted
I agree
 
- because it will be re-created if the process is repeated, right? And it's useless while the wiki's open.
I'm not sure what do you mean. Do you mean that If you download again the wiki using the appropriate method it will be generated again? if so, yes, that is correct. But I have plans to provide several download methods, so once you have generated the "databaseTiddler" you can just choose another download method that saves the wiki without re-packing the database. Anyway, I think the most reasonable way is to delete that tiddler like TW deletes the import tiddler. 
 

Do you mean that pouchdb will contain all of the tiddlers, or a separate db of some kind? 
Yes, exactly. That is the point. At the end, this is a sync adaptor, and when a sync adaptor is available TW saves the tiddlers through it. In this case pouch saves the data in the LocalStorage DB of the browser. It also allows you to sync to a remote server.
 

What would happen if you opened the file in a browser that doesn't support pouchdb? 
To be precise, is not pouchdb what is not supported, pouchdb is just a library. Pouchdb has fallback mechanisms to use whichever database the browser provides. But, if none local database is available then pouchdb will return an error, the database will not be created and the sync adaptor will not become active. I have plans to provide several tools to interact with the local database: Export database as a JSON file, import a JSON databse file to the local database  and so on. I can provide a method to unpack a database tiddler as a collection of normal tiddlers to the current wiki.
 

Will it be complicated to merge the databases later?

I have to experiment with it, but pouchdb provides revisions numbers, so in case of conflict  the tiddler/doc with the highest revision number wins. This should happen silently. Mi idea is to only pack the last revision of each tiddler.

Regards,
Richard

Thank you very much for your feedback Richard. 

Richard Smith

unread,
May 30, 2015, 10:18:25 PM5/30/15
to tiddl...@googlegroups.com
Hi Danielo,

Thankyou for the explanation. I understand much better now and agree that it's potentially very useful. I look forward to seeing it.

I will read some more about pouchdb and how it gets synced to remote server - it would be great to have a reliable, roll-your-own dropbox/evernote replacement. I've also been playing around with some of Jed's stuff, which is kind of related.

We can even imagine that one day, someone signing up for heroku or AWS or similar services might be able to install a default TW environment, that contains all the clever stuff you and everyone else are working on, to use as a reliable home for digital content and a 'social media' node/mail server etc. (getting carried away with ideas beyond my current capabilities again!)

Regards,
Richard
Reply all
Reply to author
Forward
0 new messages