Created
July 28, 2009 23:56
-
-
Save jwill/157763 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def setupDB = { | |
model.db = new FeatherDB(new FileSystemBackend()) | |
if (!model.backend.doesDatabaseExist("testdb")) { | |
try { | |
model.db.addDatabase("testdb") | |
} catch (Exception ex) { | |
ex.printStackTrace() | |
} | |
} | |
} | |
def populateDB = { | |
def d = (JSONDocument) Document.newDocument(model.backend, "testdb", "task1", "sa") | |
["title":"Task1", "text":"Go to supermarket"].each {d.put(it.key, it.value) } | |
def d2 = (JSONDocument) Document.newDocument(model.backend, "testdb", "task2", "sa") | |
["title":"Task2", "text":"Go to store"].each {d2.put(it.key, it.value) } | |
def d3 = (JSONDocument) Document.newDocument(model.backend, "testdb", "task3", "sa") | |
["title":"Task3", "text":"Go to work", "deadline":new Date()+1].each {d2.put(it.key, it.value) } | |
[d,d2,d3].each {model.db.getBackend().saveDocument(it) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment