model

package
v0.0.0-...-c50696d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chocolate

type Chocolate struct {
	ID    int64  `json:"-"`
	Name  string `json:"name"`
	Taste string `json:"taste"`
}

Chocolate is the chocolate that a user consumes in order to get fat and happy

func (Chocolate) GetID

func (c Chocolate) GetID() string

GetID to satisfy jsonapi.MarshalIdentifier interface

func (*Chocolate) SetID

func (c *Chocolate) SetID(id string) error

SetID to satisfy jsonapi.UnmarshalIdentifier interface

type User

type User struct {
	ID int64 `json:"-"`
	//rename the username field to user-name.
	Username      string      `json:"user-name"`
	PasswordHash  string      `json:"-"`
	Chocolates    []Chocolate `json:"-" gorm:"many2many:user_chocolates"`
	ChocolatesIDs []string    `json:"-" sql:"-"`
	// contains filtered or unexported fields
}

User is a generic database user

func (*User) AddToManyIDs

func (u *User) AddToManyIDs(name string, IDs []string) error

AddToManyIDs adds some new sweets that a users loves so much

func (*User) DeleteToManyIDs

func (u *User) DeleteToManyIDs(name string, IDs []string) error

DeleteToManyIDs removes some sweets from a users because they made him very sick

func (User) GetID

func (u User) GetID() string

GetID to satisfy jsonapi.MarshalIdentifier interface

func (User) GetReferencedIDs

func (u User) GetReferencedIDs() []jsonapi.ReferenceID

GetReferencedIDs to satisfy the jsonapi.MarshalLinkedRelations interface

func (User) GetReferencedStructs

func (u User) GetReferencedStructs() []jsonapi.MarshalIdentifier

GetReferencedStructs to satisfy the jsonapi.MarhsalIncludedRelations interface

func (User) GetReferences

func (u User) GetReferences() []jsonapi.Reference

GetReferences to satisfy the jsonapi.MarshalReferences interface

func (*User) SetID

func (u *User) SetID(id string) error

SetID to satisfy jsonapi.UnmarshalIdentifier interface

func (*User) SetToManyReferenceIDs

func (u *User) SetToManyReferenceIDs(name string, IDs []string) error

SetToManyReferenceIDs sets the sweets reference IDs and satisfies the jsonapi.UnmarshalToManyRelations interface

Jump to

Keyboard shortcuts

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