Skip to content

Commit

Permalink
chore: fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Mar 2, 2022
1 parent cba24c1 commit 9ead80f
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions example/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() {
}

type User struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
Emails []string
}
Expand All @@ -89,7 +89,7 @@ func (u User) String() string {
}

type Story struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Title string
AuthorID int64
Author *User `bun:"rel:belongs-to,join:author_id=id"`
Expand Down
2 changes: 1 addition & 1 deletion example/create-table-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type Book struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
CategoryID int64
}
Expand Down
2 changes: 1 addition & 1 deletion example/cursor-pagination/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {
}

type Entry struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Text string
}

Expand Down
2 changes: 1 addition & 1 deletion example/fixture/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type User struct {
}

type Org struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
OwnerID int64
Owner *User `bun:"rel:belongs-to"`
Expand Down
2 changes: 1 addition & 1 deletion example/model-hooks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func main() {
}

type User struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Password string
CreatedAt time.Time `bun:",nullzero"`
UpdatedAt time.Time `bun:",nullzero"`
Expand Down
2 changes: 1 addition & 1 deletion example/multi-tenant/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func selectStories(ctx context.Context, db *bun.DB) ([]*Story, error) {
}

type Story struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Title string
AuthorID int64
}
Expand Down
2 changes: 1 addition & 1 deletion example/opentelemetry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
}

type TestModel struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
}

Expand Down
2 changes: 1 addition & 1 deletion example/pg-faceted-search/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

type Book struct {
ID uint64
ID uint64 `bun:",pk,autoincrement"`
Name string
Tags []string
}
Expand Down
2 changes: 1 addition & 1 deletion example/placeholders/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type User struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
Emails []string
}
Expand Down
4 changes: 2 additions & 2 deletions example/rel-belongs-to/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
)

type Profile struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Lang string
}

// User has one profile.
type User struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Name string
ProfileID int64
Profile *Profile `bun:"rel:belongs-to,join=profile_id=id"`
Expand Down
4 changes: 2 additions & 2 deletions example/rel-has-many-polymorphic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ type Comment struct {
}

type Article struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string

Comments []Comment `bun:"rel:has-many,join:id=trackable_id,join:type=trackable_type,polymorphic"`
}

type Post struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string

Comments []Comment `bun:"rel:has-many,join:id=trackable_id,join:type=trackable_type,polymorphic"`
Expand Down
4 changes: 2 additions & 2 deletions example/rel-has-many/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
)

type Profile struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Lang string
Active bool
UserID int64
}

// User has many profiles.
type User struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Name string
Profiles []*Profile `bun:"rel:has-many,join:id=user_id"`
}
Expand Down
4 changes: 2 additions & 2 deletions example/rel-has-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (

// Profile belongs to User.
type Profile struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Lang string
UserID int64
}

type User struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Name string
Profile *Profile `bun:"rel:has-one,join:id=user_id"`
}
Expand Down
2 changes: 1 addition & 1 deletion example/rel-many-to-many-self/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type Item struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
Children []Item `bun:"m2m:item_to_items,join:Item=Child"`
}

Expand Down
4 changes: 2 additions & 2 deletions example/rel-many-to-many/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
)

type Order struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
// Order and Item in join:Order=Item are fields in OrderToItem model
Items []Item `bun:"m2m:order_to_items,join:Order=Item"`
}

type Item struct {
ID int64 `bun:",pk"`
ID int64 `bun:",pk,autoincrement"`
// Order and Item in join:Order=Item are fields in OrderToItem model
Orders []Order `bun:"m2m:order_to_items,join:Item=Order"`
}
Expand Down
4 changes: 2 additions & 2 deletions example/tx-composition/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func insertUserAndProfile(ctx context.Context, db bun.IDB) error {
}

type User struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
Name string
}

Expand All @@ -67,7 +67,7 @@ func InsertUser(ctx context.Context, db bun.IDB, user *User) error {
}

type Profile struct {
ID int64
ID int64 `bun:",pk,autoincrement"`
UserID int64
Email string
}
Expand Down

0 comments on commit 9ead80f

Please sign in to comment.