Nitrite db = Nitrite.builder()
.filePath("/tmp/test.db")
.openOrCreate("user", "password");
NitriteCollection collection
= db.getCollection("test");
DataGateClient dataGateClient = new DataGateClient("http://localhost:9898")
.withAuth("userId", "password");
DataGateSyncTemplate syncTemplate
= new DataGateSyncTemplate(dataGateClient, "remote-collection@userId");
SyncHandle syncHandle = Replicator.of(db)
.forLocal(collection)
.withSyncTemplate(syncTemplate)
.delay(timeSpan(1, TimeUnit.SECONDS))
.ofType(ReplicationType.BOTH_WAY)
.withListener(new SyncEventListener() {
@Override
public void onSyncEvent(SyncEventData eventInfo) {
}
})
.configure();
syncHandle.startSync();