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
78d278da
Commit
78d278da
authored
8 years ago
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Adding demo.
parent
03c946bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+46
-0
46 additions, 0 deletions
README.md
_examples/booktown-books/main.go
+1
-3
1 addition, 3 deletions
_examples/booktown-books/main.go
with
47 additions
and
3 deletions
README.md
+
46
−
0
View file @
78d278da
...
@@ -17,6 +17,52 @@ sources such as PostgreSQL, MySQL, SQLite, QL and MongoDB.
...
@@ -17,6 +17,52 @@ sources such as PostgreSQL, MySQL, SQLite, QL and MongoDB.
This is the source code repository, see examples and documentation at
This is the source code repository, see examples and documentation at
[
upper.io/db.v2
][
1
]
.
[
upper.io/db.v2
][
1
]
.
## Demo
```
go
package
main
import
(
"log"
"upper.io/db.v2/postgresql"
)
var
settings
=
postgresql
.
ConnectionURL
{
Host
:
"demo.upper.io"
,
Database
:
"booktown"
,
User
:
"demouser"
,
Password
:
"demop4ss"
,
}
type
Book
struct
{
ID
int
`db:"id"`
Title
string
`db:"title"`
AuthorID
int
`db:"author_id"`
SubjectID
int
`db:"subject_id"`
}
func
main
()
{
sess
,
err
:=
postgresql
.
Open
(
settings
)
if
err
!=
nil
{
log
.
Fatalf
(
"db.Open(): %q
\n
"
,
err
)
}
defer
sess
.
Close
()
booksCol
:=
sess
.
Collection
(
"books"
)
var
books
[]
Book
err
=
booksCol
.
Find
()
.
All
(
&
books
)
if
err
!=
nil
{
log
.
Fatalf
(
"Find(): %q
\n
"
,
err
)
}
for
i
,
book
:=
range
books
{
log
.
Printf
(
"Book %d: %#v
\n
"
,
i
,
book
)
}
}
```
## License
## License
This project is licensed under the terms of the
**MIT License**
.
This project is licensed under the terms of the
**MIT License**
.
...
...
This diff is collapsed.
Click to expand it.
_examples/booktown-books/main.go
+
1
−
3
View file @
78d278da
...
@@ -3,7 +3,6 @@ package main
...
@@ -3,7 +3,6 @@ package main
import
(
import
(
"log"
"log"
"upper.io/db.v2"
"upper.io/db.v2/postgresql"
"upper.io/db.v2/postgresql"
)
)
...
@@ -22,11 +21,10 @@ type Book struct {
...
@@ -22,11 +21,10 @@ type Book struct {
}
}
func
main
()
{
func
main
()
{
sess
,
err
:=
db
.
Open
(
"
postgresql
"
,
settings
)
sess
,
err
:=
postgresql
.
Open
(
settings
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatalf
(
"db.Open(): %q
\n
"
,
err
)
log
.
Fatalf
(
"db.Open(): %q
\n
"
,
err
)
}
}
defer
sess
.
Close
()
defer
sess
.
Close
()
booksCol
:=
sess
.
Collection
(
"books"
)
booksCol
:=
sess
.
Collection
(
"books"
)
...
...
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