This page is part of a static HTML representation of the TiddlyWiki at http://tiddlywiki.com/dev/

SyncAdaptorModules

14th August 2014 at 10:49am
dev moduletypes

Introduction

SyncAdaptorModules encapsulate storage mechanisms that can be used by the SyncMechanism. Two examples are:

SyncAdaptorModules are represented as JavaScript tiddlers with the field module-type set to syncadaptor.

Exports

The following properties should be exposed via the exports object:

PropertyDescription
adaptorClassThe JavaScript class for the adaptor

Nothing should be exported if the adaptor detects that it isn't capable of operating successfully (eg, because it only runs on either the browser or the server, or because a dependency is missing).

Adaptor Module Methods

Adaptor modules must handle the following methods.

Constructor(options)

Initialises a new adaptor instance.

ParameterDescription
optionsSee below

Options include:

  • options.wiki: reference to wiki to use with this syncadaptor

getTiddlerInfo(tiddler)

Gets the supplemental information that the adaptor needs to keep track of for a particular tiddler. For example, the TiddlyWeb adaptor includes a bag field indicating the original bag of the tiddler.

ParameterDescription
tiddlerTarget tiddler

Returns an object storing any additional information required by the adaptor.

getStatus(callback)

Retrieves status information from the server. This method is optional.

ParameterDescription
callbackCallback function invoked with parameters err,isLoggedIn,username

login(username,password,callback)

Attempts to login to the server with specified credentials. This method is optional.

ParameterDescription
usernameUsername
passwordPassword
callbackCallback function invoked with parameter err

logout(callback)

Attempts to logout of the server. This method is optional.

ParameterDescription
callbackCallback function invoked with parameter err

getSkinnyTiddlers(callback)

Retrieves a list of skinny tiddlers from the server.

This method is optional. If an adaptor doesn't implement it then synchronisation will be unidirectional from the TiddlyWiki store to the adaptor, but not the other way.

ParameterDescription
callbackCallback function invoked with parameter err,tiddlers, where tiddlers is an array of tiddler field objects

saveTiddler(tiddler,callback,tiddlerInfo)

Saves a tiddler to the server.

ParameterDescription
tiddlerTiddler to be saved
callbackCallback function invoked with parameter err,adaptorInfo,revision
tiddlerInfoThe tiddlerInfo maintained by the syncer for this tiddler

loadTiddler(title,callback)

Loads a tiddler from the server.

ParameterDescription
titleTitle of tiddler to be retrieved
callbackCallback function invoked with parameter err,tiddlerFields

deleteTiddler(title,callback,tiddlerInfo)

Delete a tiddler from the server.

ParameterDescription
titleTitle of tiddler to be deleted
callbackCallback function invoked with parameter err
tiddlerInfoThe tiddlerInfo maintained by the syncer for this tiddler