Compare commits

..

2 Commits

Author SHA1 Message Date
yequari 5cd3eeb765 fix struct variable scopes 2023-07-10 00:20:53 -07:00
yequari 2f3a4aee36 boilerplate code and documentation 2023-07-10 00:19:23 -07:00
1 changed files with 45 additions and 37 deletions

View File

@ -5,19 +5,18 @@ import (
"time"
"github.com/google/uuid"
"modernc.org/sqlite"
)
type SiteId string
type SiteEntry struct {
id SiteId
name string
webmaster *SiteWebmaster
url string
dateAdded time.Time
next SiteId
prev SiteId
Id SiteId
Name string
Webmaster *SiteWebmaster
Url string
DateAdded time.Time
Next SiteId
Prev SiteId
}
@ -26,78 +25,87 @@ func NewSiteEntry(siteName, webmasterEmail, siteUrl string) SiteEntry {
// previous site is the last one inserted
// retrieve webmaster from database or create if it doesn't exist
return SiteEntry{
id: SiteId(uuid.NewString()),
name: siteName,
url: siteUrl,
dateAdded: time.Now(),
Id: SiteId(uuid.NewString()),
Name: siteName,
Url: siteUrl,
DateAdded: time.Now(),
}
}
type WebmasterId string
type SiteWebmaster struct {
id WebmasterId
name string
email string
Id WebmasterId
Name string
Email string
}
func NewSiteWebmaster(name, email string) SiteWebmaster {
return SiteWebmaster{ id: WebmasterId(uuid.NewString()),
name: name,
email: email,
return SiteWebmaster{ Id: WebmasterId(uuid.NewString()),
Name: name,
Email: email,
}
}
type Webring struct {
Db *sql.DB
Length int
first SiteId
last SiteId
length int
}
func NewWebring(db *sql.DB) *Webring {
webring := Webring{Db: db}
return &webring
// Retrieve the first website added to the webring
func (webring *Webring) retrieveFirstSite() (*SiteEntry, error) {
return nil, nil
}
func (webring *Webring) retrieveFirstSite() (SiteEntry, error) {
}
func (webring *Webring) retrieveLastSite() (SiteEntry, error) {
// Retrieve the latest website added to the webring
func (webring *Webring) retrieveLastSite() (*SiteEntry, error) {
return nil, nil
}
// Commit a SiteEntry to the database
func (webring *Webring) CreateSiteEntry(entry *SiteEntry) error {
// commit to database
return nil
}
// Retrieve a SiteEntry from the database by id
func (webring *Webring) RetrieveSiteEntry(id SiteId) (*SiteEntry, error) {
return nil, nil
}
// Retrieve a SiteEntry from the database by url
func (webring *Webring) RetriveSiteEntryByUrl(url string) (*SiteEntry, error) {
return nil, nil
}
// Update existing SiteEntry with the values of passed entry
func (webring *Webring) UpdateSiteEntry(entry *SiteEntry) error {
// update existing SiteEntry
return nil
}
// Delete SiteEntry from database
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
// delete SiteEntry
return nil
}
// Commit a SiteWebmaster to the database
func (webring *Webring) CreateSiteWebmaster(webmaster *SiteWebmaster) error {
return nil
}
// Retrieve a SiteWebmaster from the database by id
func (webring *Webring) RetrieveSiteWebmaster(id WebmasterId) (*SiteWebmaster, error) {
return nil, nil
}
// Update a SiteWebmaster in the database with the values of the passed webmaster
func (webring *Webring) UpdateSiteWebmaster(webmaster *SiteWebmaster) error {
return nil
}
// Delete a SiteWebmaster from the database
func (webring *Webring) DeleteSiteWebmaster(webmaster *SiteWebmaster) error {
return nil
}