Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save spikeheap/9162189 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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