Compare commits

..

No commits in common. "5cd3eeb765872c116e3fe3b98ee5e33f18e6d7df" and "4be2d235380e36246dad6f7891a055ed54d2b936" have entirely different histories.

1 changed files with 37 additions and 45 deletions

View File

@ -5,18 +5,19 @@ 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
}
@ -25,87 +26,78 @@ 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
}
// Retrieve the first website added to the webring
func (webring *Webring) retrieveFirstSite() (*SiteEntry, error) {
return nil, nil
func NewWebring(db *sql.DB) *Webring {
webring := Webring{Db: db}
return &webring
}
// Retrieve the latest website added to the webring
func (webring *Webring) retrieveLastSite() (*SiteEntry, error) {
return nil, nil
func (webring *Webring) retrieveFirstSite() (SiteEntry, error) {
}
func (webring *Webring) retrieveLastSite() (SiteEntry, error) {
}
// Commit a SiteEntry to the database
func (webring *Webring) CreateSiteEntry(entry *SiteEntry) error {
return nil
// commit to database
}
// 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 {
return nil
// update existing SiteEntry
}
// Delete SiteEntry from database
func (webring *Webring) DeleteSiteEntry(entry *SiteEntry) error {
return nil
// delete SiteEntry
}
// 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
}