package main

import (
	"fmt"
	"goimgApi/accounts"
	"goimgApi/configs"
	"time"
	"github.com/joho/godotenv"
)

func main() {
	godotenv.Load(".env")
	configs.ConnectDB()
	var user accounts.User
	configs.DB.First(&user, 1)

	exp := time.Now().Add(30 * 24 * time.Hour)
	user.ApiTokenExpiresAt = &exp
	user.IsAdmin = true // Ensure admin
	
	err := configs.DB.Save(&user).Error
	if err != nil {
		fmt.Println("SAVE ERROR:", err)
	}

	var user2 accounts.User
	configs.DB.First(&user2, 1)

	if user2.ApiTokenExpiresAt != nil {
		fmt.Println("DB HAS:", *user2.ApiTokenExpiresAt)
	} else {
		fmt.Println("DB IS EMPTY")
	}
}
