Last active
August 29, 2015 13:56
-
-
Save spikeheap/9162189 to your computer and use it in GitHub Desktop.
Sample mongo connection in Groovy using gmongo
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 credential = MC.createMongoCRCredential( "server", "db", "pass".toCharArray() ) | |
| def mongoClient = new MongoClient( new ServerAddress("ds033429.mongolab.com", 33429), [ credential ] ) | |
| def mongo = new GMongo( mongoClient ) | |
| def db = mongo.getDB("CloudFoundry_8sbeqjqe_6hqm0ehp") | |
| map.each { key, value -> | |
| db.riverlevelsgroovy << value | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
spikeheap, no need to close the connection after doing the manipulations?