Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spikeheap/9162189 to your computer and use it in GitHub Desktop.
Save spikeheap/9162189 to your computer and use it in GitHub Desktop.
Sample mongo connection in Groovy using gmongo
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
}
@asuraphel
Copy link

spikeheap, no need to close the connection after doing the manipulations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment