Skip to content

Commit 3281490

Browse files
committed
rename name to locName
1 parent bb7366a commit 3281490

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

services/location/database.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ CREATE TABLE IF NOT EXISTS locations
5656
var seed = []Location{
5757
{
5858
ID: 1,
59-
Name: "My Home",
59+
LocName: "My Home",
6060
Coordinates: "231,773",
6161
},
6262
{
6363
ID: 123,
64-
Name: "Rachel's Floral Designs",
64+
LocName: "Rachel's Floral Designs",
6565
Coordinates: "115,277",
6666
},
6767
{
6868
ID: 567,
69-
Name: "Amazing Coffee Roasters",
69+
LocName: "Amazing Coffee Roasters",
7070
Coordinates: "211,653",
7171
},
7272
{
7373
ID: 392,
74-
Name: "Trom Chocolatier",
74+
LocName: "Trom Chocolatier",
7575
Coordinates: "577,322",
7676
},
7777
{
7878
ID: 731,
79-
Name: "Japanese Desserts",
79+
LocName: "Japanese Desserts",
8080
Coordinates: "728,326",
8181
},
8282
}
@@ -155,7 +155,7 @@ func (d *database) List(ctx context.Context) ([]Location, error) {
155155
var cs []Location
156156
for rows.Next() {
157157
c := Location{}
158-
if err := rows.Scan(&c.ID, &c.Name, &c.Coordinates); err != nil {
158+
if err := rows.Scan(&c.ID, &c.LocName, &c.Coordinates); err != nil {
159159
return nil, err
160160
}
161161
cs = append(cs, c)
@@ -169,12 +169,12 @@ func (d *database) List(ctx context.Context) ([]Location, error) {
169169

170170
func (d *database) Create(ctx context.Context, location *Location) (int64, error) {
171171
query := "INSERT INTO locations SET name = ?, coordinates = ?"
172-
res, err := d.db.Exec(query, location.Name, location.Coordinates)
172+
res, err := d.db.Exec(query, location.LocName, location.Coordinates)
173173
if err != nil {
174174
if !d.shouldRetry(err) {
175175
return 0, err
176176
}
177-
res, err = d.db.Exec(query, location.Name, location.Coordinates)
177+
res, err = d.db.Exec(query, location.LocName, location.Coordinates)
178178
if err != nil {
179179
return 0, err
180180
}
@@ -188,12 +188,12 @@ func (d *database) Create(ctx context.Context, location *Location) (int64, error
188188

189189
func (d *database) Update(ctx context.Context, location *Location) error {
190190
query := "UPDATE locations SET name = ?, coordinates = ? WHERE id = ?"
191-
res, err := d.db.Exec(query, location.Name, location.Coordinates, location.ID)
191+
res, err := d.db.Exec(query, location.LocName, location.Coordinates, location.ID)
192192
if err != nil {
193193
if !d.shouldRetry(err) {
194194
return err
195195
}
196-
res, err = d.db.Exec(query, location.Name, location.Coordinates, location.ID)
196+
res, err = d.db.Exec(query, location.LocName, location.Coordinates, location.ID)
197197
if err != nil {
198198
return err
199199
}
@@ -241,7 +241,7 @@ func (d *database) Get(ctx context.Context, locationID int) (*Location, error) {
241241
return nil, row.Err()
242242
}
243243
}
244-
if err := row.Scan(&c.ID, &c.Name, &c.Coordinates); err != nil {
244+
if err := row.Scan(&c.ID, &c.LocName, &c.Coordinates); err != nil {
245245
return nil, err
246246
}
247247
return &c, nil
@@ -286,7 +286,7 @@ func (d *database) setupDB() {
286286
}
287287
for i := range seed {
288288
c := &seed[i]
289-
if _, err := stmt.Exec(c.ID, c.Name, c.Coordinates); err != nil {
289+
if _, err := stmt.Exec(c.ID, c.LocName, c.Coordinates); err != nil {
290290
panic(err)
291291
}
292292
}

services/location/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
// Location contains data about a location.
2323
type Location struct {
2424
ID int64 `json:"id"`
25-
Name string `json:"name"`
25+
LocName string `json:"locName"`
2626
Coordinates string `json:"coordinates"`
2727
}
2828

0 commit comments

Comments
 (0)