create and get categories with database for user
This commit is contained in:
1 parent
2c06975a43
commit
90e5863adc
12 files changed
+189
-79
No files matched your search
@@ -13,7 +13,9 @@ import (
|
||||
|
||||
func CreateCategory(category *model.Category) error {
|
||||
e := Db.Where(model.Category{
|
||||
Title: category.Title,
|
||||
Title: category.Title,
|
||||
UserID: category.UserID,
|
||||
Type: category.Type,
|
||||
}).FirstOrCreate(&category).Error
|
||||
if e != nil {
|
||||
return e
|
||||
@@ -75,9 +77,9 @@ func GetCategoriesFromFile(filename string) []model.Category {
|
||||
return res
|
||||
}
|
||||
|
||||
func GetAllCategories() ([]model.Category, error) {
|
||||
func GetAllCategories(userid string) ([]model.Category, error) {
|
||||
var categories []model.Category
|
||||
e := Db.Find(&categories).Error
|
||||
e := Db.Where(model.Category{UserID: userid}).Find(&categories).Error
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user