create and get categories with database for user
Build and Test / build-and-test-backend (push) Successful in 31s
Build and Test / build-and-test-frontend (push) Successful in 34s

This commit is contained in:
wt committed 2025-08-09 17:32:18 +07:00
1 parent 2c06975a43
commit 90e5863adc
12 files changed
+189 -79

No files matched your search

+5 -3
View File
@@ -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
}