Created
March 10, 2016 13:32
-
-
Save tomblench/53ebc015ab4021936f60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void blah() throws Exception { | |
Map<String, String> map = new HashMap<String, String>(); | |
map.put("hello", "world"); | |
// create a doc | |
DocumentRevision revision = new DocumentRevision("id1"); | |
revision.setBody(DocumentBodyFactory.create(map)); | |
datastore.createDocumentFromRevision(revision); | |
// fetch up to 100 changes since the beginning | |
Changes changes = datastore.changes(0, 100); | |
// prints id1 | |
for (DocumentRevision rev : changes.getResults()) { | |
System.out.println(rev); | |
} | |
// store the current sequence since the last document create/update | |
long currentSequence = datastore.getLastSequence(); | |
// create 2 docs | |
DocumentRevision revision2 = new DocumentRevision("id2"); | |
DocumentRevision revision3 = new DocumentRevision("id3"); | |
revision2.setBody(DocumentBodyFactory.create(map)); | |
revision3.setBody(DocumentBodyFactory.create(map)); | |
datastore.createDocumentFromRevision(revision2); | |
datastore.createDocumentFromRevision(revision3); | |
// fetch up to 100 change since last create/update | |
changes = datastore.changes(currentSequence, 100); | |
/// prints id2, id3 | |
for (DocumentRevision rev : changes.getResults()) { | |
System.out.println(rev); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment