database

package
v0.0.0-...-9992a52 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2018 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
	Postgres bool
	Temp     bool
}

Config for the database.

func (Config) Connect

func (c Config) Connect() (*gorm.DB, error)

Connect attempt to connect to the database based on the config options.

type Station

type Station struct {
	gorm.Model

	// User filled in information.
	Name   string `json:"name"`
	Slug   string `json:"slug"`
	Public bool   `json:"public"`

	// Relationships between users and tracks.
	Users []*User `gorm:"many2many:user_stations;" json:"users"`
	Track []Track `json:"audio"`

	// Streams
	Streams []Stream
}

A Station holds the audio tracks and users.

type Stream

type Stream struct {
	gorm.Model

	Host        string `json:"host" gorm:"default:'127.0.0.1'"`
	Port        int    `json:"port" gorm:"default:'8080'"`
	Mount       string `json:"mount" gorm:"default:'stream'"`
	User        string `json:"user" gorm:"default:'source'"`
	Password    string `json:"password" gorm:"default:'hackme'"`
	Name        string `json:"stream_name"`
	URL         string `json:"url"`
	Genre       string `json:"genre" gorm:"default:'rock'"`
	Description string `json:"description"`
	BufferSize  int    `json:"buffer_size" gorm:"default:'3'"`
	StationID   uint   `json:"station_id"`
}

Stream has the information about a stream.

type Tag

type Tag struct {
	gorm.Model

	// Information that is visible to the station users.
	Text      string `json:"text"`
	TrackID   uint   `json:"audio_id"`
	StationID uint   `json:"station_id"`
}

Tag holds information that can be assigned to multiple tracks within a station.

type Track

type Track struct {
	gorm.Model

	// Necessary information.
	Album  string `json:"album" gorm:"default:'Unknown Album'"`
	Artist string `json:"artist" gorm:"default:'Unknown Artist'"`
	Title  string `json:"title" gorm:"default:'Unknown Title'"`
	Year   string `json:"year" gorm:"default:'1776'"`

	// Optional information.
	Genre string `json:"genre"`
	Tags  []Tag  `json:"tags"`

	// Calculated information.
	Processed bool    `json:"processed"`
	Length    float64 `json:"length"`
	Location  string  `json:"location"`
	StationID uint    `json:"organization_id"`
	Tempo     int     `json:"tempo"`
	UserID    uint    `json:"uploader"`
}

Track is the information needed to store a audio file.

type User

type User struct {
	gorm.Model

	// Only the user can change this information.
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`

	// Relationship between the users and the stations.
	Stations []*Station `gorm:"many2many:user_stations;" json:"stations"`
}

User is the information about the user for icii.

type UserPermission

type UserPermission struct {
	gorm.Model

	UserID    uint `json:"user_id"`
	StationID uint `json:"station_id"`

	// Station track permissions.
	TrackRead  bool `json:"track_read"`  // See what tracks are available.
	TrackWrite bool `json:"track_write"` // Edit, add, or remove tracks.

	// Station user permissions.
	UserRead  bool `json:"user_read"`  // See the users in the station.
	UserWrite bool `json:"user_write"` // Add or remove users, or edit their permissions.

	// Station stream permissions.
	StreamRead  bool `json:"stream_read"`  // See the station's streams.
	StreamWrite bool `json:"stream_write"` // Edit, add, or remove streams.

	// Station permissions.
	StationRead  bool `json:"station_read"`  // See private station information.
	StationWrite bool `json:"station_write"` // Edit, add, or remove station information.

	// Schedule permissions.
	ScheduleRead  bool `json:"schedule_read"`  // See the schedule for the station.
	ScheduleWrite bool `json:"schedule_write"` // Edit the station schedule.

	// Playlist permissions.
	PlaylistRead  bool `json:"playlist_read"`  // See the playlist.
	PlaylistWrite bool `json:"playlist_write"` // Edit, add, or remove a playlist.

}

UserPermission keeps track of what permission are allowed for a user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL