Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select custom database #13

Merged
merged 2 commits into from
Jan 11, 2017

Conversation

ilijamt
Copy link
Contributor

@ilijamt ilijamt commented Jan 11, 2017

Allow to select the database name for every collection. Useful if you want to allow people to switch databases. Which I needed to do easily.

Everything remains the same, with just one addition. When you create a collection, it will have a database name inside, and that collection will always point to the same database.

conf := &Config{
	ConnectionString: "localhost",
	Database:         "bongotest",
}

conn, err := Connect(conf)

    colBongoTest := conn.Collection("test")

colTestNewDBName := conn.CollectionFromDatabase("test", "NewDBName")
colTestOtherDB := conn.CollectionFromDatabase("test", "OtherDB")

References PR #12 , I've merged into master before creating the branch for this.

@coveralls
Copy link

coveralls commented Jan 11, 2017

Coverage Status

Coverage increased (+0.5%) to 84.706% when pulling 91ba6ba on ilijamt:select-custom-database into 5314e13 on maxwellhealth:master.

@securingsincity
Copy link
Contributor

Thanks @ilijamt !

@securingsincity securingsincity merged commit c2a7770 into go-bongo:master Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants