odk-sync
Experimental - use with caution, may not be supported in the future
synchronize odk data
api
var Sync = require('odk-sync')
var sync = Sync(opts)
Create a new odk sync instance.
opts.db
- required leveldb instanceopts.log
- required hyperlog instance
var stream = sync.replicate(opts, cb)
Create a duplex stream
for replication.
When replication is finished cb(err)
fires.
Optionally:
opts.live
- whentrue
, keep replication open
sync.importDevice(dir, cb)
Import a directory of odk data from the file system at dir
.
sync.importFiles(files, cb)
Import an array of browser File
objects file
. You can use this method with
drag-drop to drop an odk directory into a web page.
cb(err, docs)
fires with an array of docs
. Each doc
in docs
:
doc.files
- an array of string keys for attached filesdoc.info
- odk form data
var stream = sync.list(opts, cb)
List odk records as a readable stream
or collect the records as
cb(null, docs)
. Each doc
in docs
has:
doc.files
- an array of string keys for attached filesdoc.info
- odk form data
var geostream = sync.geojson(opts, cb)
List odk records as a stream
of geojson data or collect a string of geojson as
cb(err, str)
.
sync.read(key, cb)
Read all the documents under key
as cb(err, streams)
.