// Package models provides the data models and database connection package models import "gorm.io/gorm" type CardDeck struct { gorm.Model UserID uint User User Title string `json:"title"` Description string `json:"description"` Cards []Card `json:"cards"` } type CardDeckDto struct { ID uint `json:"id"` Title string `json:"title"` Description string `json:"description"` Cards []CardDto `json:"cards"` } func (c CardDeck) ToDto() CardDeckDto { dto := CardDeckDto{ID: c.ID, Title: c.Title, Description: c.Description} for _, card := range c.Cards { dto.Cards = append(dto.Cards, card.ToDto()) } return dto }