Skip to content
Rodrigo Alves edited this page Dec 8, 2013 · 5 revisions

Groundhog comes with built-in support for MongoDB as data storage system. Here's how you can get started:

// Establishes connection with the local MongoDB server
// declaring the host of Mongo and the name of the DB
GroundhogDB db = new GroundhogDB("127.0.0.1", "myGitHubResearch");

Project project = new Project("yahoo", "samoa");

// Fetches all commits of the project and persists each one of them to the database
List<Commit> commits = searchGitHub.getAllProjectCommits(project);

for (Commit comm: commits) {
    db.save(comm);
    System.out.println(comm);
}

Querying within the MongoDB shell

Here is a brief tutorial of how you can browse MongoDB itself throughout its CLI commands (Shell) to check for data obtained via Groundhog (assuming you're logged into the MongoDB shell already):

use myGitHubResearch; // the same DB name you provided when using the Groundhog DB class
show collections;     // displays a list of all Groundhog entities persisted within the DB

db.commits.count();   // counts how many commits are persisted already. You can - of course - replace 'commits' in this command for any other Groudhog collection that is already in the DB

db.commits.find().toArray(); // Lists all commit objects already persisted

Sample query response within the MongoDB shell

Here's a sample query response for db.commits.find().toArray();:

[
	{
		"_id" : ObjectId("52a48d75036493cec0388624"),
		"className" : "br.ufpe.cin.groundhog.Commit",
		"sha" : "03d42a6cd83b32385e4949b11195cf5e3a683014",
		"commiter" : {
			"id" : 703859,
			"login" : "gdfm",
			"hireable" : false,
			"followers" : 0,
			"following" : 0,
			"public_repos" : 0,
			"public_gists" : 0
		},
		"message" : "Update README.md",
		"commitDate" : ISODate("2013-12-05T19:37:11Z"),
		"additionsCount" : 0,
		"deletionsCount" : 0
	}
]

TO-DO

  • Add persistence coverage for all existing GitHub entities
  • Add query support within Groundhog
  • Add more tests

Clone this wiki locally