diff options
Diffstat (limited to 'model/recipe.go')
| -rw-r--r-- | model/recipe.go | 16 | 
1 files changed, 9 insertions, 7 deletions
| diff --git a/model/recipe.go b/model/recipe.go index 1510379..e5cf0a6 100644 --- a/model/recipe.go +++ b/model/recipe.go @@ -3,23 +3,24 @@ package model  import (  	"database/sql"  	"errors" +	"fmt"  	"time"  )  type Recipe struct { -	Id          int64  `json:"id"` +	Id          string `json:"id"`  	Title       string `json:"title"` -	Portions    int    `json:"portions"` +	Portions    string `json:"portions"`  	Url         string `json:"url"`  	Notes       string `json:"notes"` -	Created     int64  `json:"created"` -	LastChanged int64  `json:"last_changed"` +	Created     string `json:"created"` +	LastChanged string `json:"last_changed"`  }  func (r *Recipe) Create() error {  	now := time.Now().Unix() -	r.Created = now -	r.LastChanged = now +	r.Created = fmt.Sprint(now) +	r.LastChanged = r.Created  	query := `INSERT INTO recipes      (title, portions, url, notes, created, last_changed) @@ -32,10 +33,11 @@ VALUES  		return err  	} -	r.Id, err = result.LastInsertId() +	id, err := result.LastInsertId()  	if err != nil {  		return err  	} +	r.Id = fmt.Sprint(id)  	return nil  } | 
