@@ -4,16 +4,16 @@ sidebar_position: 2
44
55# Creating a Connection
66
7- All Connections in Elemental are managed by the ` e_connection ` package which can be imported as follows:
7+ All Connections in Elemental are managed by the ` elemental ` package which can be imported as follows:
88
99``` go
10- import " github.com/elcengine/elemental/connection "
10+ import " github.com/elcengine/elemental/core "
1111```
1212
1313Connecting to a MongoDB database is a simple as calling the ` ConnectURI ` function with your connection string:
1414
1515``` go
16- client := e_connection. ConnectURI (" mongodb://localhost:27017" )
16+ client := elemental. Connect (" mongodb://localhost:27017" )
1717```
1818
1919## Connecting with Custom Client Options
@@ -22,7 +22,7 @@ You can also pass custom client options from the `go.mongodb.org/mongo-driver/mo
2222
2323``` go
2424opts := options.Client ().SetTimeout (10 * time.Second )
25- client := e_connection .Connect (e_connection .ConnectionOptions {
25+ client := elemental .Connect (elemental .ConnectionOptions {
2626 URI : " mongodb://localhost:27017" ,
2727 ClientOptions : opts,
2828})
@@ -37,7 +37,7 @@ An alias is a human-readable name that you can assign to your connection. This i
3737A connection without an alias is assigned the default alias ** ` default ` **
3838
3939``` go
40- client := e_connection .Connect (e_connection .ConnectionOptions {
40+ client := elemental .Connect (elemental .ConnectionOptions {
4141 Alias : " my-connection" ,
4242 URI : " mongodb://localhost:27017" ,
4343})
@@ -46,45 +46,45 @@ client := e_connection.Connect(e_connection.ConnectionOptions{
4646## Retrieve a Connection by Alias
4747
4848``` go
49- client := e_connection .GetConnection (" my-connection" )
49+ client := elemental .GetConnection (" my-connection" )
5050```
5151
5252## Retrieve the default database in a Connection
5353
5454- Returns the default database in the default connection
5555
5656``` go
57- db := e_connection. UseDefault ()
57+ db := elemental. UseDefaultDatabase ()
5858```
5959
6060- Returns the default database in the connection with the alias "my-connection"
6161
6262``` go
63- db := e_connection. UseDefault (" my-connection" )
63+ db := elemental. UseDefaultDatabase (" my-connection" )
6464```
6565
6666## Retrieve any database in a Connection
6767
6868- Returns the database "my-database" in the default connection
6969
7070``` go
71- db := e_connection. Use (" my-database" )
71+ db := elemental. UseDatabase (" my-database" )
7272```
7373
7474- Returns the database "my-database" in the connection with the alias "my-connection"
7575
7676``` go
77- db := e_connection. Use (" my-database" , " my-connection" )
77+ db := elemental. UseDatabase (" my-database" , " my-connection" )
7878```
7979
8080## Disconnect from a Connection
8181
8282``` go
83- e_connection .Disconnect ()
83+ elemental .Disconnect ()
8484```
8585
8686- Or disconnect from multiple connections
8787
8888``` go
89- e_connection .Disconnect (" default" , " my-connection" , " some-other-connection" )
89+ elemental .Disconnect (" default" , " my-connection" , " some-other-connection" )
9090```
0 commit comments