task can be added

This commit is contained in:
Florian Hoss 2022-04-06 20:59:10 +02:00
parent 87e66f74bd
commit f73f862bcf
4 changed files with 64 additions and 15 deletions

View file

@ -34,6 +34,17 @@ func (db *Database) GetAllTasks() []Task {
return tasks
}
func (db *Database) CreateTask(username string, description string) Task {
task := Task{
ID: 0,
Username: username,
Description: description,
Done: false,
}
db.ORM.Create(&task)
return task
}
func (db *Database) CreateUser(username string, password string) error {
user := User{Username: username, Password: password}
result := db.ORM.Create(&user)

View file

@ -17,6 +17,7 @@ type User struct {
type Task struct {
ID int `gorm:"primaryKey"`
Username string
Description string
Done bool
}