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
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
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
GitLab 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
fb0acc16
Commit
fb0acc16
authored
Mar 10, 2013
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Adding an example and another paragraph.
parent
2c016079
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+32
-1
32 additions, 1 deletion
README.md
with
32 additions
and
1 deletion
README.md
+
32
−
1
View file @
fb0acc16
...
@@ -27,12 +27,43 @@ for i, item := range items {
...
@@ -27,12 +27,43 @@ for i, item := range items {
}
}
```
```
`db.Collection.FindAll()`
will accept different structures in no special order,
in the above example we are passing a
`db.Cond{}`
type, that's a condition,
you could also use
`db.And{}`
,
`db.Or{}`
,
`db.Limit(n)`
,
`db.Offset(n)`
, etc.
each one of them having different meanings.
While this level of abstraction would not be able to represent a complex query
While this level of abstraction would not be able to represent a complex query
or to use any database-specific features it's fairly convenient for doing the
or to use any database-specific features it's fairly convenient for doing the
simple CRUD stuff
. A
nd for advanced queries the underlying driver is always
simple CRUD stuff
, a
nd for advanced queries the underlying driver is always
exposed as a
`*sql.DB`
or a
`*mgo.Session`
so you can still be able to use
exposed as a
`*sql.DB`
or a
`*mgo.Session`
so you can still be able to use
any database-pro spells.
any database-pro spells.
Fetching all rows may be not so adequate for processing large datasets, in that
case we can use
`db.Collection.Query()`
instead of
`db.Collection.FindAll()`
and
then iterate over the results.
```
go
// Makes a query and stores the result.
res
,
err
=
people
.
Query
(
db
.
Cond
{
"name"
:
"john"
},
)
if
err
!=
nil
{
panic
(
err
.
Error
())
}
person
:=
struct
{
Name
string
}{}
for
true
{
// res.Next() will accept a pointer to map or struct.
err
=
res
.
Next
(
&
person
)
if
err
!=
nil
{
break
}
// fmt.Printf("%v\n", person)
}
```
One of the features you may find useful is the ability of
`gosexy/db`
to make
One of the features you may find useful is the ability of
`gosexy/db`
to make
relations between different databases that talk different protocols with ease:
relations between different databases that talk different protocols with ease:
...
...
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