good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
upper
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
open
upper
Commits
c56e26fb
Commit
c56e26fb
authored
12 years ago
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Adding full example
parent
5e13bb87
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+63
-0
63 additions, 0 deletions
README.md
with
63 additions
and
0 deletions
README.md
+
63
−
0
View file @
c56e26fb
...
...
@@ -103,6 +103,69 @@ for _, item := range items {
The same example goes for other drivers with few modifications, just change the driver name to
`mysql`
,
`postgresql`
or
`sqlite`
.
### Full example
```
go
#
_examples
/
mongo
.
go
package
main
import
(
"fmt"
"github.com/gosexy/db"
_
"github.com/gosexy/db/mongo"
"github.com/gosexy/sugar"
)
const
host
=
"debian"
const
dbname
=
"dev"
func
main
()
{
sess
,
err
:=
db
.
Open
(
"mongo"
,
db
.
DataSource
{
Host
:
host
,
Database
:
dbname
})
if
err
!=
nil
{
panic
(
err
)
}
defer
sess
.
Close
()
sess
.
Drop
()
animals
,
_
:=
sess
.
Collection
(
"animals"
)
animals
.
Append
(
db
.
Item
{
"animal"
:
"Bird"
,
"young"
:
"Chick"
,
"female"
:
"Hen"
,
"male"
:
"Cock"
,
"group"
:
"flock"
,
})
animals
.
Append
(
db
.
Item
{
"animal"
:
"Bovidae"
,
"young"
:
"Calf"
,
"female"
:
"Cow"
,
"male"
:
"Bull"
,
"group"
:
"Herd"
,
})
animals
.
Append
(
db
.
Item
{
"animal"
:
"Canidae"
,
"young"
:
sugar
.
List
{
"Puppy"
,
"Pup"
},
"female"
:
"Bitch"
,
"male"
:
"Dog"
,
"group"
:
"Pack"
,
})
items
:=
animals
.
FindAll
()
for
_
,
item
:=
range
items
{
fmt
.
Printf
(
"animal: %s, young: %s
\n
"
,
item
[
"animal"
],
item
[
"young"
])
}
}
```
## Documentation
To know how to query the database you've just connected, please read the
[
online reference
](
http://gosexy.org/db
)
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment