From 6fb69cc9c26c70ce54a1bf8ccf8ce8a7d2b957b8 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Mon, 3 May 2021 22:00:10 +0530 Subject: the people api now also gives the ID of the client --- server/database/people.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/database/people.go b/server/database/people.go index 6083af4..01cbba8 100644 --- a/server/database/people.go +++ b/server/database/people.go @@ -13,8 +13,8 @@ package database import ( _ "github.com/mattn/go-sqlite3" ) - type Person struct { + ID int Name string Phone string Email string @@ -23,16 +23,17 @@ type Person struct { func GetAllPeople() []Person { var allPeople []Person rows, _ := myDatabase.Query( - `SELECT Name, Phone, Email FROM People`, + `SELECT id, Name, Phone, Email FROM People`, ) var ( name, phone, email string + id int ) for rows.Next() { - rows.Scan(&name, &phone, &email) - allPeople = append(allPeople, Person{name, phone, email}) + rows.Scan(&id, &name, &phone, &email) + allPeople = append(allPeople, Person{id, name, phone, email}) } return allPeople -- cgit v1.2.3