abstraction

This commit is contained in:
2024-12-29 19:48:41 -05:00
parent fe4b5b6033
commit 0b36bcbd6a
8 changed files with 221 additions and 193 deletions

21
api/db.go Normal file
View File

@@ -0,0 +1,21 @@
package api
import "errors"
func dbGetUser(id int64) (*User, error) {
for _, u := range users {
if u.ID == id {
return u, nil
}
}
return nil, errors.New("User not found")
}
func dbGetMessage(id string) (*Message, error) {
for _, a := range messages {
if a.ID == id {
return a, nil
}
}
return nil, errors.New("Message not found")
}