-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Kalissaac/add-connection-string
Add support for MongoDB connection string
- Loading branch information
Showing
3 changed files
with
42 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,22 +41,30 @@ store := mongodb.New() | |
|
||
// Initialize custom config | ||
store := mongodb.New(mongodb.Config{ | ||
Atlas: false, | ||
Host: "127.0.0.1", | ||
Port: 27017, | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
}) | ||
|
||
// Initialize custom config using connection string | ||
store := mongodb.New(mongodb.Config{ | ||
ConnectionURI: "mongodb://user:[email protected]:27017", | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
}) | ||
|
||
``` | ||
|
||
### Config | ||
```go | ||
type Config struct { | ||
// Whether the DB is hosted on MongoDB Atlas | ||
// Connection string to use for DB. Will override all other authentication values if used | ||
// | ||
// Optional. Default is false | ||
Atlas bool | ||
// Optional. Default is "" | ||
ConnectionURI string | ||
|
||
// Host name where the DB is hosted | ||
// | ||
|
@@ -98,11 +106,11 @@ type Config struct { | |
### Default Config | ||
```go | ||
var ConfigDefault = Config{ | ||
Atlas: false, | ||
Host: "127.0.0.1", | ||
Port: 27017, | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
ConnectionURI: "", | ||
Host: "127.0.0.1", | ||
Port: 27017, | ||
Database: "fiber", | ||
Collection: "fiber_storage", | ||
Reset: false, | ||
} | ||
``` |
This file contains 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
This file contains 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