Hi Danielo,
good to see that you are making progress, I am very interested in seeing
this working.
From I can tell, I would start with the browser only and get it to work
there, since that seems to be the core use-case of the whole thing.
Later though, I can imagine that there probably won't be many changes
needed to get it to work with nodejs, since essentially this is how the
syncing-pipeline should be:
Browser ---tiddlyweb---> NodeJS server ---PouchDB---> PouchDB server
When you take a look at modules/startup/startup.js (this is where the
syncer is initialized), you will see that it is in fact possible to deny
a potential PouchDB adaptor to be exectued in the browser, when the
TiddlyWeb adaptor is presented (and loaded before your adaptor).
I would not try to create a server and a client side database, as this
duplicates existing functionality (remember, the whole nodejs saving
thingy does exactly the same) and from what I understand the
localStorage in the PouchDB adaptor is only meant for temporary storage
with the end goal of syncicng to a CouchDB, right ?
So it makes sense to limit this kind of localStorage to only one of the
TW instances involved in a nodejs-setup (which should be the server
since that is where all the changes made, come together).
Again though, try not to worry about nodejs just yet, get it working in
the browser first.
/Andreas
Am 25.05.2015 um 10:57 schrieb Danielo Rodríguez:
Ok,
This is what I have done so far, please let me know if it is correc:
1. I added pouch-db as a library module
2. I have created an startup module that looks like this
|
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Export name and synchronous status
exports.name = "pouchdb";
exports.after = ["startup"];
exports.synchronous = true;
exports.startup = function() {
var PouchDB =
require("$:/plugins/danielo515/tiddlypouch/pouchdb.js");
$tw.database = new PouchDB('tiddlywiki');
};
})();
|
I'm thinking about limiting it to browser scope. I know that pouchdb
can work both on browser and node, but I'm not sure how to handle this
at node side, and how should the plugin behave. Maybe to create two
pouch databases (server side and client side) and sync between them?
El lunes, 25 de mayo de 2015, 8:59:44 (UTC+2), Danielo Rodríguez
escribió:
Hello everyone,
As usual, I want to create a new plugin, but I have some lack of
knowledge at certain areas. This one is about where is the best
place to instantiate the database object that has to be used. As
you probably know, pouchdb is a javascript database you can talk
to, but you have to do it through an object. Where is the best
place to instantiate that object? Note that you only have to
create it once, and talk to it on subsequent save/load operations.
I though about creating it in the part of the adapter where it is
instantiated, but I'm not sure about this.
Thanks for any hint.
--
You received this message because you are subscribed to the Google
Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/1ef7b7c4-0693-4682-a3f1-0f2dfa8198d4%40googlegroups.com
<https://groups.google.com/d/msgid/tiddlywikidev/1ef7b7c4-0693-4682-a3f1-0f2dfa8198d4%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywikidev/5562FA4A.4020301%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.