db

package
v0.0.0-...-b10e7cb Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	// User that account belongs to
	User *User
	// TokenType of the account
	TokenType string
	// Refresh token of the account
	RefreshToken string
	// Email associated to the account
	Email string
	// Kind of the account
	Kind int
	// AccessToken of the account
	AccessToken string
	// InternalID of the account
	ID int
	// Whether if the account is the principal one
	Principal bool
	// List of all calendars associated to the account on DB
	Calendars []Calendar
}

Account mapped from db

type Calendar

type Calendar struct {
	// UUID of the calendar
	UUID uuid.UUID
	// Email associated to the account
	AccountEmail string
	// Account which the calendar belongs to
	Account Account
	// Name of the calendar
	Name string
	// ID of the calendar
	ID string
	// Parent calendar of the calendar
	ParentUUID uuid.UUID
	// Subscription uuid of the calendar
	SubscriptionUUID uuid.UUID
	// List of calendars that are related to this one
	Calendars []Calendar
}

Calendar mapped from db

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database object for the frontend

func New

func New(client *sql.DB, sentry *raven.Client) Database

Function that creates a new database instance

func (Database) AddAccount

func (data Database) AddAccount(user *User, account Account) (id int, err error)

Method that saves an account to the user on db

func (Database) AddCalendarsRelation

func (data Database) AddCalendarsRelation(user *User, parentCalendarUUID string, calendarIDs []string) (err error)

Method that creates the relations between calendars

func (Database) AddCalendarsToAccount

func (data Database) AddCalendarsToAccount(user *User, account Account, values []string) (err error)

Method that saves calendars to an account

func (Database) Close

func (data Database) Close() error

Method that closes the database client

func (Database) DeleteCalendar

func (data Database) DeleteCalendar(user *User, id string) (err error)

Method that removes a calendar from the db

func (Database) FindAccount

func (data Database) FindAccount(user *User, ID int) (account Account, err error)

Method that finds an account by its id that belongs to a user

func (Database) FindCalendars

func (data Database) FindCalendars(account *Account) (err error)

Gets calendars from an account

func (Database) FindOrCreateUser

func (data Database) FindOrCreateUser(user *User) (err error)

Method that finds an user or creates one if it is not stored

func (Database) RetrieveUser

func (data Database) RetrieveUser(uuid string) (user *User, err error)

Method that retrieves the user from the db

func (Database) SetUserAccounts

func (data Database) SetUserAccounts(user *User) (err error)

Method that retrieves all accounts of the user

func (Database) UpdateCalendar

func (data Database) UpdateCalendar(user *User, calendarID string, parentID string) (err error)

Method that updates a calendar

type User

type User struct {
	// UUID of the user
	UUID uuid.UUID
	// Email of the user
	Email string
	// Name of the user
	Name string
	// Principal Account of the user
	PrincipalAccount Account
	// Accounts associated with user that are not principal
	Accounts []Account
}

User mapped from db

Jump to

Keyboard shortcuts

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