Skip to content

Commit d94a5a5

Browse files
foxishdavixcky
authored andcommitted
rename name to locName
1 parent 3a55d11 commit d94a5a5

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
}
@@ -154,7 +154,7 @@ func (d *database) List(ctx context.Context) ([]Location, error) {
154154
var cs []Location
155155
for rows.Next() {
156156
c := Location{}
157-
if err := rows.Scan(&c.ID, &c.Name, &c.Coordinates); err != nil {
157+
if err := rows.Scan(&c.ID, &c.LocName, &c.Coordinates); err != nil {
158158
return nil, err
159159
}
160160
cs = append(cs, c)
@@ -168,12 +168,12 @@ func (d *database) List(ctx context.Context) ([]Location, error) {
168168

169169
func (d *database) Create(ctx context.Context, location *Location) (int64, error) {
170170
query := "INSERT INTO locations SET name = ?, coordinates = ?"
171-
res, err := d.db.Exec(query, location.Name, location.Coordinates)
171+
res, err := d.db.Exec(query, location.LocName, location.Coordinates)
172172
if err != nil {
173173
if !d.shouldRetry(err) {
174174
return 0, err
175175
}
176-
res, err = d.db.Exec(query, location.Name, location.Coordinates)
176+
res, err = d.db.Exec(query, location.LocName, location.Coordinates)
177177
if err != nil {
178178
return 0, err
179179
}
@@ -187,12 +187,12 @@ func (d *database) Create(ctx context.Context, location *Location) (int64, error
187187

188188
func (d *database) Update(ctx context.Context, location *Location) error {
189189
query := "UPDATE locations SET name = ?, coordinates = ? WHERE id = ?"
190-
res, err := d.db.Exec(query, location.Name, location.Coordinates, location.ID)
190+
res, err := d.db.Exec(query, location.LocName, location.Coordinates, location.ID)
191191
if err != nil {
192192
if !d.shouldRetry(err) {
193193
return err
194194
}
195-
res, err = d.db.Exec(query, location.Name, location.Coordinates, location.ID)
195+
res, err = d.db.Exec(query, location.LocName, location.Coordinates, location.ID)
196196
if err != nil {
197197
return err
198198
}
@@ -240,7 +240,7 @@ func (d *database) Get(ctx context.Context, locationID int) (*Location, error) {
240240
return nil, row.Err()
241241
}
242242
}
243-
if err := row.Scan(&c.ID, &c.Name, &c.Coordinates); err != nil {
243+
if err := row.Scan(&c.ID, &c.LocName, &c.Coordinates); err != nil {
244244
return nil, err
245245
}
246246
return &c, nil
@@ -285,7 +285,7 @@ func (d *database) setupDB() {
285285
}
286286
for i := range seed {
287287
c := &seed[i]
288-
if _, err := stmt.Exec(c.ID, c.Name, c.Coordinates); err != nil {
288+
if _, err := stmt.Exec(c.ID, c.LocName, c.Coordinates); err != nil {
289289
panic(err)
290290
}
291291
}

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)