db

package
v0.0.0-...-0915ee4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2017 License: AGPL-3.0 Imports: 16 Imported by: 0

README

Nerdz - Database interface

This document is legacy and may not be reliable.

In this folder you can find the NERDZ back-end implementation.

Back-end types architecture

In the implementation of the NERDZ's type hierarchy, a lot of data structure are generated in order to manipulate all the information that the social network manages. All the data structure are filled by a database ORM that is used to avoid to rely on the specific query dialect when creating each query. In order to work with it, a specific type has been defined in the file types.go which contains specific details that grant to the ORM to manage all the database's logic.

All the information it's not simply generated and consumed inside the system. In making available an API, we need to decouple all the internal data structure from the one that are returned to the user by the system. It's absolutely NOT correct to return all the data exactly has they are stored in the database. For this reason, according to the state-of-the-art pattern of the Transfer Object, we have defined a main structure and a specific transfer object type which can be generated from it.

In particular, each type defined in the file types.go implements a specific interface, called Transferable, which let to it to define how will be generated the companion transfer object type defined in the file api_types.go. Each transfer object type associated to the main struct, doesn't have all the ORM details and is completely seperated from the database's logic.

Working in this way, will be necessary, to get each transfer object specific type for a data structure, to work a little with type conversion and type switch. In a first moment this could be really tedious, but this approach has a lot of benefits that are appreciable only in the long-run.

Back-end tests

Tests are based on nerdz-test-db. If you want to run rests you must correctly setup this environment.

cd ~/nerdz_env/
git clone https://github.com/nerdzeu/nerdz-test-db.git

You don't need to do anything else in that folder.

Come back here and properly setup your JSON configuration file in order to use a new test-db.

Mine looks like:

{
    "DbUsername" : "test_db",
    "DbPassword" : "test_db",
    "DbName"     : "test_db",
    "DbHost"     : "127.0.0.1",
    "DbPort"     : 0,
    "DbSSLMode"    : "disable",
    "NERDZPath"  : "/home/paolo/nerdz_env/nerdz.eu/",
    "NERDZHost"  : "local.nerdz.eu",
    "EnableLog"  : true,
    "Port"       : 9090,
    "Scheme"     : "http",
    "Host"       : "local.api.nerdz.eu"
}

After that, configure the nvironment variables into test_all.sh.

Run the tests

To run all the test, you need a working database. If you wanto to automatically create a new database, use ./test_all.sh.

If your nerdz-test-db is just ready thus you don't need to create a new one, you can lunch tests in these two ways:

CONF_FILE="/path/to/conf_file/conf_file_name" go test

If you want to see which queries are executed run tests with EnableLog parameter set to true in the configuration file and using the verbose mode for the test tool:

CONF_FILE="/path/to/conf_file/conf_file_name" go test -v |less

Documentation

Index

Constants

View Source
const (
	// MinPosts represents the minimum posts number that can be required in a postList
	MinPosts uint64 = 1
	// MaxPosts represents the maximum posts number that can be required in a postList
	MaxPosts uint64 = 20

	// MinComments represents the minimum comments number that can be required in a commentList
	MinComments uint64 = 1
	// MaxComments represents the maximum comments number that can be required in a commentList
	MaxComments uint64 = 20
)
View Source
const (
	// UserBoardID constant (of type boardType) makes possible to distinguish a User
	// board from a Project board
	UserBoardID boardType = "user"
	// ProjectBoardID constant (of type boardType) makes possible to distinguish a PROJECT
	// board from a User board
	ProjectBoardID boardType = "project"
)
View Source
const (
	// MinPms represents the minimum pms number that can be required in a conversation
	MinPms uint64 = 1
	// MaxPms represents the maximum pms number that can be required in a conversation
	MaxPms uint64 = 20
)

Variables

View Source
var (
	// Languages contains the languages supported by the current NERDZ implementation.
	Languages = utils.StringSet{
		"de": struct{}{},
		"en": struct{}{},
		"hr": struct{}{},
		"it": struct{}{},
		"pt": struct{}{},
		"ro": struct{}{},
	}
)

Functions

func AtMostComments

func AtMostComments(n uint64) uint8

AtMostComments returns a uint64 that's the number of comments to be retrieved

func AtMostPms

func AtMostPms(n uint64) uint8

AtMostPms returns a uint64 that's the number of pms to be retrieved

func AtMostPosts

func AtMostPosts(n uint64) uint8

AtMostPosts returns a uint8 that's the number of posts to be retrieved

func Init

func Init() error

Init initialises the internal Database instance. Using the package before calling Init will cause the application to panic.

Types

type Ban

type Ban struct {
	User       uint64
	Motivation string
	Time       time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter    uint64    `igor:"primary_key"`
}

Ban is the model for the relation ban

func (Ban) TableName

func (Ban) TableName() string

TableName returns the table name associated with the structure

type Blacklist

type Blacklist struct {
	From       uint64
	To         uint64
	Motivation string
	Time       time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter    uint64    `igor:"primary_key"`
}

Blacklist is the model for the relation blacklist

func (Blacklist) TableName

func (Blacklist) TableName() string

TableName returns the table name associated with the structure

type Board

type Board interface {
	Info() *Info
	// The return value type of Postlist must be changed by type assertion.
	Postlist(PostlistOptions) *[]ExistingPost
}

Board is the interface that wraps the methods common to every board. Every board has its own Informations and Postlist

type BoardInfo

type BoardInfo struct {
	Language   string
	IsClosed   bool
	Private    bool
	Whitelist  []*User
	UserScript *url.URL
}

BoardInfo is that struct that contains all the informations related to the user's board

type Bookmark

type Bookmark interface {
	// contains filtered or unexported methods
}

Bookmark is a generic interface to represent a bookmark

type CommentlistOptions

type CommentlistOptions struct {
	N     uint8  // number of comments to return
	Older uint64 // if specified, tells to the function that is using this struct to return N comments OLDER (created before) than the comment with the spefified "Older" ID
	Newer uint64 // if specified, tells to the function that is using this struct to return N comments NEWER (created after) than the comment with the spefified "Newer" ID
}

CommentlistOptions is used to specify the options for a list of comments

type ContactInfo

type ContactInfo struct {
	Website  *url.URL
	GitHub   *url.URL
	Skype    string
	Jabber   string
	Yahoo    *mail.Address
	Facebook *url.URL
	Twitter  *url.URL
	Steam    string
}

ContactInfo is the struct that contains all the contact info of an user

type Content

type Content interface {
	igor.DBModel
	Reference
	TextHolder

	SetSender(uint64)
	SetReference(uint64)
	SetLanguage(string) error
	ClearDefaults()

	Sender() *User
	NumericSender() uint64
	Reference() Reference
	NumericReference() uint64
	IsEditable() bool
	NumericOwners() []uint64
	Owners() []*User
	Revisions() []string
	RevisionsNumber() uint8
	VotesCount() int
	Votes() *[]Vote
}

Content represents a generic message used by Nerdz. Implementations: (UserPost, ProjectPost, UserPostComment, ProjectPostComment, Pm)

type Conversation

type Conversation struct {
	From        uint64
	To          uint64
	LastMessage string
	Time        time.Time
	ToRead      bool
}

Conversation represents the details about a single private conversation between two users

type DeletedUser

type DeletedUser struct {
	Counter    uint64 `igor:"primary_key"`
	Username   string
	Time       time.Time `sql:"default:(now() at time zone 'utc')"`
	Motivation string
}

DeletedUser is the model for the relation deleted_users

func (DeletedUser) TableName

func (DeletedUser) TableName() string

TableName returns the table name associated with the structure

type ExistingComment

type ExistingComment interface {
	Content

	Post() (ExistingPost, error)
}

ExistingComment is the interface that wraps the methods common to every existing comment

type ExistingPost

type ExistingPost interface {
	Content

	Comments(CommentlistOptions) *[]ExistingComment
	CommentsCount() uint8
	NumericBookmarkers() []uint64
	Bookmarkers() []*User
	BookmarksCount() uint8
	Bookmarks() *[]Bookmark
	NumericLurkers() []uint64
	Lurkers() []*User
	LurkersCount() uint8
	Lurks() *[]Lurk
	IsClosed() bool
	NumericType() uint8
	Type() string
}

ExistingPost is the interface that wraps the methods common to every existing post

type Info

type Info struct {
	ID       uint64
	Owner    *Info
	Name     string
	Username string
	Website  *url.URL
	Image    *url.URL
	Closed   bool
	Type     boardType
}

Info contains the informations common to every board Used in API output to give user/project basic informations

func Infos

func Infos(slice interface{}) []*Info

Infos returns a slice of pointer to Info

type Interest

type Interest struct {
	ID    uint64 `igor:"primary_key"`
	From  uint64
	Value string
	Time  time.Time `sql:"default:(now() at time zone 'utc')"`
}

Interest is the model for the relation interests

func (Interest) TableName

func (Interest) TableName() string

TableName returns the table name associated with the structure

type Lock

type Lock interface {
	// contains filtered or unexported methods
}

Lock is a generic interface to represent the Lock action

type Lurk

type Lurk interface {
	// contains filtered or unexported methods
}

Lurk is a generic interface to represent the Lurk action

type Mention

type Mention struct {
	ID       uint64 `igor:"primary_key"`
	UHpid    uint64
	GHpid    uint64
	From     uint64
	To       uint64
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	ToNotify bool
}

Mention is the model for the relation mentions

func (Mention) TableName

func (Mention) TableName() string

TableName returns the table name associated with the structure

type Message

type Message struct {
	Post
	Type uint8
}

Message is the model for the view message

func (Message) TableName

func (Message) TableName() string

TableName returns the table name associated with the structure

type OAuth2AccessData

type OAuth2AccessData struct {
	ID uint64 `igor:"primary_key"`
	// ClientID references the client that created this token
	ClientID uint64
	// CreatedAt is the instant of creation of the OAuth2AccessToken
	CreatedAt time.Time `sql:"default:(now() at time zone 'utc')"`
	// ExpiresIn is the seconds from CreatedAt before this token expires
	ExpiresIn uint64
	// RedirectUri is the RedirectUri associated with the token
	RedirectURI string
	// AuthorizeDataID references the AuthorizationData that authorizated this token. Can be null
	AuthorizeDataID sql.NullInt64 `igor:"column:oauth2_authorize_id"` // Annotation required, since the column name does not follow igor conventions
	// AccessDataID references the Access Data, for refresh token. Can be null
	AccessDataID sql.NullInt64 `igor:"column:oauth2_access_id"` // Annotation required, since the column name does not follow igor conventions
	// RefreshTokenID is the value by which this token can be renewed. Can be null
	RefreshTokenID sql.NullInt64
	// AccessToken is the main value of this tructure, represents the access token
	AccessToken string
	// Scope is the requested scope
	Scope string
	// UserID is references the User that created The access request and thus the AccessData
	UserID uint64
}

OAuth2AccessData is the OAuth2 access data

func (OAuth2AccessData) TableName

func (OAuth2AccessData) TableName() string

TableName returns the table name associated with the structure

type OAuth2AuthorizeData

type OAuth2AuthorizeData struct {
	// Surrogated key
	ID uint64 `igor:"primary_key"`
	// ClientID references the client that created this token
	ClientID uint64
	// Code is the Authorization code
	Code string
	// CreatedAt is the instant of creation of the OAuth2AuthorizeToken
	CreatedAt time.Time `sql:"default:(now() at time zone 'utc')"`
	// ExpiresIn is the seconds from CreatedAt before this token expires
	ExpiresIn uint64
	// State data from request
	//State string, [!] we dont't store state variables
	// Scope is the requested scope
	Scope string
	// RedirectUri is the RedirectUri associated with the token
	RedirectURI string
	// UserID is references the User that created the authorization request and thus the AuthorizeData
	UserID uint64
}

OAuth2AuthorizeData is the model for the relation oauth2_authorize that represents the authorization granted to to the client

func (OAuth2AuthorizeData) TableName

func (OAuth2AuthorizeData) TableName() string

TableName returns the table name associated with the structure

type OAuth2Client

type OAuth2Client struct {
	// Surrogated key
	ID uint64 `igor:"primary_key"`
	// Real Primary Key. Application (client) name
	Name string `sql:"UNIQUE"`
	// Secret is the unique secret associated with a client
	Secret string `sql:"UNIQUE"`
	// RedirectURI is the valid redirection URI associated with a client
	RedirectURI string
	// UserID references User that created this client
	UserID uint64
}

OAuth2Client implements the osin.Client interface

func (OAuth2Client) TableName

func (OAuth2Client) TableName() string

TableName returns the table name associated with the structure

type OAuth2RefreshToken

type OAuth2RefreshToken struct {
	ID    uint64 `igor:"primary_key"`
	Token string `sql:"UNIQUE"`
}

OAuth2RefreshToken is the model for the relation oauth2_refresh

func (OAuth2RefreshToken) TableName

func (OAuth2RefreshToken) TableName() string

TableName returns the table name associated with the structure

type PM

type PM struct {
	Pmid    uint64 `igor:"primary_key"`
	From    uint64
	To      uint64
	Message string
	Lang    string
	ToRead  bool
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
}

PM is the model for the relation pms

func NewPm

func NewPm(pmid uint64) (*PM, error)

NewPm initializes a Pm struct

func NewPmWhere

func NewPmWhere(description *PM) (pm *PM, e error)

NewPmWhere returns the *Pm fetching the first one that matches the description

func (*PM) ClearDefaults

func (pm *PM) ClearDefaults()

ClearDefaults set to the go's default values the fields with default sql values

func (*PM) ID

func (pm *PM) ID() uint64

ID returns the User Post ID

func (*PM) IsEditable

func (pm *PM) IsEditable() bool

IsEditable returns true if the pm is editable

func (*PM) Language

func (pm *PM) Language() string

Language returns the message language

func (*PM) NumericOwners

func (pm *PM) NumericOwners() []uint64

NumericOwners returns a slice of ids of the owner of the pms (the ones that can perform actions)

func (*PM) NumericReference

func (pm *PM) NumericReference() uint64

NumericReference returns the id of the recipient user

func (*PM) NumericSender

func (pm *PM) NumericSender() uint64

NumericSender returns the id of the sender user

func (*PM) Owners

func (pm *PM) Owners() (ret []*User)

Owners returns a slice of *User representing the users who own the pm

func (*PM) Reference

func (pm *PM) Reference() Reference

Reference returns the recipient *User

func (*PM) Revisions

func (pm *PM) Revisions() (modifications []string)

Revisions returns all the revisions of the message

func (*PM) RevisionsNumber

func (pm *PM) RevisionsNumber() uint8

RevisionsNumber returns the number of the revisions

func (*PM) Sender

func (pm *PM) Sender() *User

Sender returns the sender *User

func (*PM) SetLanguage

func (pm *PM) SetLanguage(language string) error

SetLanguage set the language of the pm (useless)

func (*PM) SetReference

func (pm *PM) SetReference(id uint64)

SetReference sets the destionation of the pm: user ID

func (*PM) SetSender

func (pm *PM) SetSender(id uint64)

SetSender sets the source of the pm (the user ID)

func (*PM) SetText

func (pm *PM) SetText(message string)

SetText set the text of the message

func (PM) TableName

func (PM) TableName() string

TableName returns the table name associated with the structure

func (*PM) Text

func (pm *PM) Text() string

Text returns the pm message

func (*PM) Votes

func (pm *PM) Votes() (votes *[]Vote)

Voters returns a slice of *Vote representing the votes

func (*PM) VotesCount

func (pm *PM) VotesCount() int

Votes returns the pm's votes value

type PersonalInfo

type PersonalInfo struct {
	IsOnline  bool
	Nation    string
	Timezone  string
	Username  string
	Name      string
	Surname   string
	Gender    bool
	Birthday  time.Time
	Gravatar  *url.URL
	Interests []string
	Quotes    []string
	Biography string
}

PersonalInfo is the struct that contains all the personal info of an user

type PmsOptions

type PmsOptions struct {
	N     uint8  // number of pms to return
	Older uint64 // if specified, tells to the function that is using this struct to return N pms OLDER (created before) than the pms with the specified "Older" ID
	Newer uint64 // if specified, tells to the function that is using this struct to return N pms NEWER (created after) than the comment with the spefified "Newer" ID
}

PmsOptions represent the configuration used to fetch a Pm list

type Post

type Post struct {
	Hpid    uint64 `igor:"primary_key"`
	From    uint64
	To      uint64
	Pid     uint64 `sql:"default:0"`
	Message string
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Lang    string
	News    bool
	Closed  bool
}

Post is the type of a generic post

func (*Post) ProjectPost

func (p *Post) ProjectPost() *ProjectPost

ProjectPost converts the Post to ProjectPost

func (*Post) UserPost

func (p *Post) UserPost() *UserPost

UserPost converts the Post to a UserPost

type PostClassification

type PostClassification struct {
	ID    uint64 `igor:"primary_key"`
	UHpid uint64
	GHpid uint64
	Tag   string
}

PostClassification is the model for the relation posts_classifications

func (PostClassification) TableName

func (PostClassification) TableName() string

TableName returns the table name associated with the structure

type PostlistOptions

type PostlistOptions struct {
	Model      igor.DBModel // igor.DBModel used to apply filter (like language) to avoid conflics while doing joins
	Following  bool         // true -> show posts only FROM following
	Followers  bool         // true -> show posts only FROM followers
	Language   string       // if Language is a valid 2 characters identifier, show posts from users (users selected enabling/disabling following & folowers) speaking that Language
	N          uint8        // number of posts to return
	Older      uint64       // if specified, tells to the function using this struct to return N posts OLDER (created before) than the post with the specified "Older" ID
	OlderModel igor.DBModel // igor.DBModel required when the older identifier is fetched from a view
	Newer      uint64       // if specified, tells to the function using this struct to return N posts NEWER (created after) the post with the specified "Newer" ID
	NewerModel igor.DBModel // igor.DBModel required when the newer identifier is fetched from a view
}

PostlistOptions is used to specify the options for a list of posts. The 4 fields are documented and can be combined.

If Following = Followers = true -> show posts FROM user that I follow that follow me back (friends) If Older != 0 && Newer != 0 -> find posts BETWEEN this 2 posts

For example: - user.UserHome(&PostlistOptions{Followed: true, Language: "en"}) returns at most the last 20 posts from the english speaking users that I follow. - user.UserHome(&PostlistOptions{Followed: true, Following: true, Language: "it", Older: 90, Newer: 50, N: 10}) returns at most 10 posts, from user's friends, speaking italian, between the posts with hpid 90 and 50

type Profile

type Profile struct {
	Counter        uint64 `igor:"primary_key"`
	Website        string
	Quotes         string
	Biography      string
	Github         string
	Skype          string
	Jabber         string
	Yahoo          string
	Userscript     string
	Template       uint8
	MobileTemplate uint8
	Dateformat     string
	Facebook       string
	Twitter        string
	Steam          string
	Push           bool
	Pushregtime    time.Time `sql:"default:(now() at time zone 'utc')"`
	Closed         bool
}

Profile is the model for the relation profiles

func (Profile) TableName

func (Profile) TableName() string

TableName returns the table name associated with the structure

type Project

type Project struct {
	Counter      uint64 `igor:"primary_key"`
	Description  string
	Name         string
	Private      bool
	Photo        sql.NullString
	Website      sql.NullString
	Goal         string
	Visible      bool
	Open         bool
	CreationTime time.Time `sql:"default:(now() at time zone 'utc')"`
}

Project is the model for the relation groups

func NewProject

func NewProject(id uint64) (*Project, error)

NewProject returns the user with the specified id

func NewProjectWhere

func NewProjectWhere(description *Project) (project *Project, e error)

NewProjectWhere returns the first user that matches the description

func Projects

func Projects(ids []uint64) []*Project

Projects returns a slice of pointer to Project, fetched from its Ids

func (*Project) Followers

func (prj *Project) Followers() []*User

Followers returns a []*User that follows the project

func (*Project) ID

func (prj *Project) ID() uint64

ID returns the project ID

func (*Project) Info

func (prj *Project) Info() *Info

Info returns a *info struct

func (*Project) Language

func (prj *Project) Language() string

Language returns the project language

func (*Project) Members

func (prj *Project) Members() []*User

Members returns a slice of Users members of the project

func (*Project) NumericFollowers

func (prj *Project) NumericFollowers() (followers []uint64)

NumericFollowers returns a slice containing the IDs of users that followed this project

func (*Project) NumericMembers

func (prj *Project) NumericMembers() (members []uint64)

NumericMembers returns a slice containing the IDs of users that are member of this project

func (*Project) NumericOwner

func (prj *Project) NumericOwner() (owner uint64)

NumericOwner returns the Id of the owner of the project

func (*Project) Owner

func (prj *Project) Owner() (owner *User)

Owner returns the *User owner of the project

func (*Project) Postlist

func (prj *Project) Postlist(options PostlistOptions) *[]ExistingPost

Postlist returns the specified posts on the project

func (*Project) ProjectInfo

func (prj *Project) ProjectInfo() *ProjectInfo

ProjectInfo returns a ProjectInfo struct

func (Project) TableName

func (Project) TableName() string

TableName returns the table name associated with the structure

type ProjectFollower

type ProjectFollower struct {
	From     uint64
	To       uint64
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	ToNotify bool
	Counter  uint64 `igor:"primary_key"`
}

ProjectFollower is the model for the relation groups_followers

func (ProjectFollower) TableName

func (ProjectFollower) TableName() string

TableName returns the table name associated with the structure

type ProjectInfo

type ProjectInfo struct {
	ID               uint64
	Owner            *User
	Members          []*User
	NumericMembers   []uint64
	Followers        []*User
	NumericFollowers []uint64
	Description      string
	Name             string
	Photo            *url.URL
	Website          *url.URL
	Goal             string
	Visible          bool
	Private          bool
	Open             bool
}

ProjectInfo is the struct that contains all the project's informations

type ProjectMember

type ProjectMember struct {
	From     uint64
	To       uint64
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	ToNotify bool
	Counter  uint64 `igor:"primary_key"`
}

ProjectMember is the model for the relation groups_members

func (ProjectMember) TableName

func (ProjectMember) TableName() string

TableName returns the table name associated with the structure

type ProjectNotify

type ProjectNotify struct {
	From    uint64
	To      uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Hpid    uint64
	Counter uint64 `igor:"primary_key"`
}

ProjectNotify is the model for the relation groups_notify

func (ProjectNotify) TableName

func (ProjectNotify) TableName() string

TableName returns the table name associated with the structure

type ProjectOwner

type ProjectOwner struct {
	From     uint64
	To       uint64
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	ToNotify bool
	Counter  uint64 `igor:"primary_key"`
}

ProjectOwner is the model for the relation groups_owners

func (ProjectOwner) TableName

func (ProjectOwner) TableName() string

TableName returns the table name associated with the structure

type ProjectPost

type ProjectPost struct {
	Post
}

ProjectPost is the model for the relation groups_posts

func NewProjectPost

func NewProjectPost(hpid uint64) (*ProjectPost, error)

NewProjectPost initializes a ProjectPost struct

func NewProjectPostWhere

func NewProjectPostWhere(description *ProjectPost) (post *ProjectPost, e error)

NewProjectPostWhere returns the *ProjectPost fetching the first one that matches the description

func (*ProjectPost) Bookmarkers

func (post *ProjectPost) Bookmarkers() []*User

Bookmarks returns a slice of users that bookmarked the post

func (*ProjectPost) Bookmarks

func (post *ProjectPost) Bookmarks() *[]Bookmark

Bookmarks returns a pointer to a slice of Bookmark

func (*ProjectPost) BookmarksCount

func (post *ProjectPost) BookmarksCount() (count uint8)

BookmarksCount returns the number of users that bookmarked the post

func (*ProjectPost) ClearDefaults

func (post *ProjectPost) ClearDefaults()

ClearDefaults set to the go's default values the fields with default sql values

func (*ProjectPost) Comments

func (post *ProjectPost) Comments(options CommentlistOptions) *[]ExistingComment

Comments returns the full comments list, or the selected range of comments Comments(options) returns the comment list, using selected options

func (*ProjectPost) CommentsCount

func (post *ProjectPost) CommentsCount() (count uint8)

CommentsCount returns the number of comment's post

func (*ProjectPost) ID

func (post *ProjectPost) ID() uint64

ID returns the Project Post ID

func (*ProjectPost) IsClosed

func (post *ProjectPost) IsClosed() bool

IsClosed reuturns ture if the post is closed

func (*ProjectPost) IsEditable

func (post *ProjectPost) IsEditable() bool

IsEditable returns true if the ProjectPost is editable

func (*ProjectPost) Language

func (post *ProjectPost) Language() string

Language returns the message language

func (*ProjectPost) Locks

func (post *ProjectPost) Locks() *[]Lock

Locks returns a pointer to a slice of Lock

func (*ProjectPost) Lurkers

func (post *ProjectPost) Lurkers() []*User

Lurkers returns a slice of users that are lurking the post

func (*ProjectPost) LurkersCount

func (post *ProjectPost) LurkersCount() (count uint8)

LurkersCount returns the number of users that are lurking the post

func (*ProjectPost) Lurks

func (post *ProjectPost) Lurks() *[]Lurk

Lurks returns a pointer to a slice of Lurk

func (*ProjectPost) NumericBookmarkers

func (post *ProjectPost) NumericBookmarkers() (bookmarkers []uint64)

NumericBookmarkers returns a slice of uint64 representing the ids of the users that bookmarked the post

func (*ProjectPost) NumericLurkers

func (post *ProjectPost) NumericLurkers() (lurkers []uint64)

NumericLurkers returns a slice of uint64 representing the ids of the users that lurked the post

func (*ProjectPost) NumericOwners

func (post *ProjectPost) NumericOwners() (ret []uint64)

NumericOwners returns a slice of ids of the owner of the posts (the ones that can perform actions)

func (*ProjectPost) NumericReference

func (post *ProjectPost) NumericReference() uint64

NumericReference returns the id of the recipient project

func (*ProjectPost) NumericSender

func (post *ProjectPost) NumericSender() uint64

NumericSender returns the id of the sender user

func (*ProjectPost) NumericType

func (*ProjectPost) NumericType() uint8

NumericType returns the numeric type of the post

func (*ProjectPost) Owners

func (post *ProjectPost) Owners() (ret []*User)

Owners returns a slice of *User representing the users who own the post

func (*ProjectPost) Reference

func (post *ProjectPost) Reference() Reference

Reference returns the recipient *Project

func (*ProjectPost) Revisions

func (post *ProjectPost) Revisions() (modifications []string)

Revisions returns all the revisions of the message

func (*ProjectPost) RevisionsNumber

func (post *ProjectPost) RevisionsNumber() (count uint8)

RevisionsNumber returns the number of the revisions

func (*ProjectPost) Sender

func (post *ProjectPost) Sender() *User

Sender returns the sender *User

func (*ProjectPost) SetLanguage

func (post *ProjectPost) SetLanguage(language string) error

SetLanguage set the language of the post

func (*ProjectPost) SetReference

func (post *ProjectPost) SetReference(id uint64)

SetReference set the destionation of the post. Project ID

func (*ProjectPost) SetSender

func (post *ProjectPost) SetSender(id uint64)

SetSender set the source of the post (the user ID)

func (*ProjectPost) SetText

func (post *ProjectPost) SetText(message string)

SetText set the text of the message

func (ProjectPost) TableName

func (ProjectPost) TableName() string

TableName returns the table name associated with the structure

func (*ProjectPost) Text

func (post *ProjectPost) Text() string

Text returns the post message

func (*ProjectPost) Type

func (*ProjectPost) Type() string

Type returns a string representing the post type

func (*ProjectPost) Votes

func (post *ProjectPost) Votes() *[]Vote

Votes returns a pointer to a slice of Vote

func (*ProjectPost) VotesCount

func (post *ProjectPost) VotesCount() (sum int)

Votes returns the post's votes value

type ProjectPostBookmark

type ProjectPostBookmark struct {
	Hpid    uint64
	From    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostBookmark is the model for the relation groups_bookmarks

func (*ProjectPostBookmark) NumericReference

func (bookmark *ProjectPostBookmark) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostBookmark) NumericSender

func (bookmark *ProjectPostBookmark) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostBookmark) Reference

func (bookmark *ProjectPostBookmark) Reference() Reference

Reference returns the reference of the bookmark

func (*ProjectPostBookmark) Sender

func (bookmark *ProjectPostBookmark) Sender() (user *User)

Sender returns the User that casted the bookmark

func (ProjectPostBookmark) TableName

func (ProjectPostBookmark) TableName() string

TableName returns the table name associated with the structure

type ProjectPostComment

type ProjectPostComment struct {
	Hcid     uint64 `igor:"primary_key"`
	Hpid     uint64
	From     uint64
	To       uint64
	Message  string
	Lang     string
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	Editable bool      `sql:"default:true"`
}

ProjectPostComment is the model for the relation groups_comments

func NewProjectPostComment

func NewProjectPostComment(hcid uint64) (comment *ProjectPostComment, e error)

NewProjectPostComment initializes a ProjectPostComment struct

func NewProjectPostCommentWhere

func NewProjectPostCommentWhere(description *ProjectPostComment) (comment *ProjectPostComment, e error)

NewProjectPostCommentWhere returns the *ProjectPostComment fetching the first one that matches the description

func (*ProjectPostComment) ClearDefaults

func (comment *ProjectPostComment) ClearDefaults()

ClearDefaults set to the go's default values the fields with default sql values

func (*ProjectPostComment) ID

func (comment *ProjectPostComment) ID() uint64

ID returns the comment ID

func (*ProjectPostComment) IsEditable

func (comment *ProjectPostComment) IsEditable() bool

IsEditable returns true if the comment is editable

func (*ProjectPostComment) Language

func (comment *ProjectPostComment) Language() string

Language returns the message language

func (*ProjectPostComment) NumericOwners

func (comment *ProjectPostComment) NumericOwners() []uint64

NumericOwners returns a slice of ids of the owner of the comment (the ones that can perform actions)

func (*ProjectPostComment) NumericReference

func (comment *ProjectPostComment) NumericReference() uint64

NumericReference returns the id of the recipient Post

func (*ProjectPostComment) NumericSender

func (comment *ProjectPostComment) NumericSender() uint64

NumericSender returns the id of the sender user

func (*ProjectPostComment) Owners

func (comment *ProjectPostComment) Owners() []*User

Owners returns a slice of *User representing the users who own the comment

func (*ProjectPostComment) Post

func (comment *ProjectPostComment) Post() (ExistingPost, error)

Post returns the ExistingPost sturct to which the projectComment is related

func (*ProjectPostComment) Reference

func (comment *ProjectPostComment) Reference() Reference

Reference returns the recipient *ProjectPost

func (*ProjectPostComment) Revisions

func (comment *ProjectPostComment) Revisions() (modifications []string)

Revisions returns all the revisions of the message

func (*ProjectPostComment) RevisionsNumber

func (comment *ProjectPostComment) RevisionsNumber() (count uint8)

RevisionsNumber returns the number of the revisions

func (*ProjectPostComment) Sender

func (comment *ProjectPostComment) Sender() *User

Sender returns the sender *User

func (*ProjectPostComment) SetLanguage

func (comment *ProjectPostComment) SetLanguage(language string) error

SetLanguage set the language of the comment

func (*ProjectPostComment) SetReference

func (comment *ProjectPostComment) SetReference(hpid uint64)

SetReference set the destination of the comment

func (*ProjectPostComment) SetSender

func (comment *ProjectPostComment) SetSender(id uint64)

SetSender set the source of the comment (the user ID)

func (*ProjectPostComment) SetText

func (comment *ProjectPostComment) SetText(message string)

SetText set the text of the message

func (ProjectPostComment) TableName

func (ProjectPostComment) TableName() string

TableName returns the table name associated with the structure

func (*ProjectPostComment) Text

func (comment *ProjectPostComment) Text() string

Text returns the post message

func (*ProjectPostComment) Votes

func (comment *ProjectPostComment) Votes() *[]Vote

Votes returns a pointer to a slice of Vote

func (*ProjectPostComment) VotesCount

func (comment *ProjectPostComment) VotesCount() (sum int)

Votes returns the post's votes value

type ProjectPostCommentRevision

type ProjectPostCommentRevision struct {
	Hcid    uint64
	Message string
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	RevNo   uint16
	Counter uint64 `igor:"primary_key"`
}

ProjectPostCommentRevision is the model for the relation groups_comments_revisions

func (ProjectPostCommentRevision) TableName

func (ProjectPostCommentRevision) TableName() string

TableName returns the table name associated with the structure

type ProjectPostCommentVote

type ProjectPostCommentVote struct {
	Hcid    uint64
	From    uint64
	To      uint64
	Vote    int8
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostCommentVote is the model for the relation groups_comment_thumbs

func (*ProjectPostCommentVote) NumericReference

func (vote *ProjectPostCommentVote) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostCommentVote) NumericSender

func (vote *ProjectPostCommentVote) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostCommentVote) Reference

func (vote *ProjectPostCommentVote) Reference() Reference

Reference returns the reference of the vote

func (*ProjectPostCommentVote) Sender

func (vote *ProjectPostCommentVote) Sender() (user *User)

Sender returns the User that casted the vote

func (ProjectPostCommentVote) TableName

func (ProjectPostCommentVote) TableName() string

TableName returns the table name associated with the structure

func (*ProjectPostCommentVote) Value

func (vote *ProjectPostCommentVote) Value() int8

Value returns the vote's value

type ProjectPostCommentsNotify

type ProjectPostCommentsNotify struct {
	From    uint64
	To      uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostCommentsNotify is the model for the relation groups_comments_notify

func (ProjectPostCommentsNotify) TableName

func (ProjectPostCommentsNotify) TableName() string

TableName returns the table name associated with the structure

type ProjectPostLock

type ProjectPostLock struct {
	User    uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostLock is the model for the relation groups_posts_no_notify

func (*ProjectPostLock) NumericReference

func (lock *ProjectPostLock) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostLock) NumericSender

func (lock *ProjectPostLock) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostLock) Reference

func (lock *ProjectPostLock) Reference() Reference

Reference returns the reference of the lurk

func (*ProjectPostLock) Sender

func (lock *ProjectPostLock) Sender() (user *User)

Sender returns the User that casted the lock

func (ProjectPostLock) TableName

func (ProjectPostLock) TableName() string

TableName returns the table name associated with the structure

type ProjectPostLurk

type ProjectPostLurk struct {
	Hpid    uint64
	From    uint64
	To      uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostLurk is the model for the relation groups_lurkers

func (*ProjectPostLurk) NumericReference

func (lurk *ProjectPostLurk) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostLurk) NumericSender

func (lurk *ProjectPostLurk) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostLurk) Reference

func (lurk *ProjectPostLurk) Reference() Reference

Reference returns the reference of the lurk

func (*ProjectPostLurk) Sender

func (lurk *ProjectPostLurk) Sender() (user *User)

Sender returns the User that casted the lurk

func (ProjectPostLurk) TableName

func (ProjectPostLurk) TableName() string

TableName returns the table name associated with the structure

type ProjectPostRevision

type ProjectPostRevision struct {
	Hpid    uint64
	Message string
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	RevNo   uint16
	Counter uint64 `igor:"primary_key"`
}

ProjectPostRevision is the model for the relation groups_posts_revisions

func (ProjectPostRevision) TableName

func (ProjectPostRevision) TableName() string

TableName returns the table name associated with the structure

type ProjectPostUserLock

type ProjectPostUserLock struct {
	From    uint64
	To      uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

ProjectPostUserLock is the model for the relation groups_comments_no_notify

func (*ProjectPostUserLock) NumericReference

func (lock *ProjectPostUserLock) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostUserLock) NumericSender

func (lock *ProjectPostUserLock) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostUserLock) Reference

func (lock *ProjectPostUserLock) Reference() Reference

Reference returns the reference of the lurk

func (*ProjectPostUserLock) Sender

func (lock *ProjectPostUserLock) Sender() (user *User)

Sender returns the User that casted the lock

func (ProjectPostUserLock) TableName

func (ProjectPostUserLock) TableName() string

TableName returns the table name associated with the structure

type ProjectPostVote

type ProjectPostVote struct {
	Hpid    uint64
	From    uint64
	To      uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Vote    int8
	Counter uint64 `igor:"primary_key"`
}

ProjectPostVote is the model for the relation groups_thumbs

func (*ProjectPostVote) NumericReference

func (vote *ProjectPostVote) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*ProjectPostVote) NumericSender

func (vote *ProjectPostVote) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*ProjectPostVote) Reference

func (vote *ProjectPostVote) Reference() Reference

Reference returns the reference of the vote

func (*ProjectPostVote) Sender

func (vote *ProjectPostVote) Sender() (user *User)

Sender returns the User that casted the vote

func (ProjectPostVote) TableName

func (ProjectPostVote) TableName() string

TableName returns the table name associated with the structure

func (*ProjectPostVote) Value

func (vote *ProjectPostVote) Value() int8

Value returns the vote's value

type Reference

type Reference interface {
	ID() uint64
	Language() string
}

Reference represents a reference. A comment refers to a user/project post A post, refers to a user/project board

type SpecialProject

type SpecialProject struct {
	Role    string `igor:"primary_key"`
	Counter uint64
}

SpecialProject is the model for the relation special_groups

func (SpecialProject) TableName

func (SpecialProject) TableName() string

TableName returns the table name associated with the structure

type SpecialUser

type SpecialUser struct {
	Role    string `igor:"primary_key"`
	Counter uint64
}

SpecialUser is the model for the relation special_users

func (SpecialUser) TableName

func (SpecialUser) TableName() string

TableName returns the table name associated with the structure

type TextHolder

type TextHolder interface {
	SetText(string)
	Text() string
}

TextHolder represents a text-based type

type User

type User struct {
	Counter          uint64    `igor:"primary_key"`
	Last             time.Time `sql:"default:(now() at time zone 'utc')"`
	NotifyStory      igor.JSON `sql:"default:'{}'::jsonb"`
	Private          bool
	Lang             string
	Username         string
	Password         string
	RemoteAddr       string
	HTTPUserAgent    string `igor:"column:http_user_agent"`
	Email            string
	Name             string
	Surname          string
	Gender           bool
	BirthDate        time.Time `sql:"default:(now() at time zone 'utc')"`
	BoardLang        string
	Timezone         string
	Viewonline       bool
	RegistrationTime time.Time `sql:"default:(now() at time zone 'utc')"`
	// Relation. Manually fill the field when required
	Profile Profile `sql:"-"`
}

User is the model for the relation users

func Login

func Login(login, password string) (*User, error)

Login initializes a User struct if login (id | email | username) and password are correct

func NewUser

func NewUser(id uint64) (*User, error)

NewUser returns the user with the specified id

func NewUserWhere

func NewUserWhere(description *User) (user *User, e error)

NewUserWhere returns the first user that matches the description

func Users

func Users(ids []uint64) []*User

Users returns a slice of pointer to User, fetched from its Ids

func (*User) AddInterest

func (user *User) AddInterest(interest *Interest) error

AddInterest adds the specified interest. An error is returned if the interests already exists or some DBMS contraint is violated

func (*User) Blacklist

func (user *User) Blacklist() []*User

Blacklist returns a slice of users that user (*Project) put in his blacklist

func (*User) BlacklistUser

func (user *User) BlacklistUser(other *User, motivation string) error

BlacklistUser add other user to the user blacklist

func (*User) Blacklisting

func (user *User) Blacklisting() []*User

Blacklisting returns a slice of users that puts user (*User) in their blacklist

func (*User) BoardInfo

func (user *User) BoardInfo() *BoardInfo

BoardInfo returns a *BoardInfo struct

func (*User) Bookmark

func (user *User) Bookmark(post ExistingPost) (Bookmark, error)

Bookmark bookmarks the specified post by a specific user. An error is returned if the post isn't defined or if there are other errors returned by the DBMS

func (*User) CanBookmark

func (user *User) CanBookmark(message ExistingPost) bool

CanBookmark returns true if user haven't bookamrked to existingPost yet

func (*User) CanComment

func (user *User) CanComment(message ExistingPost) bool

CanComment returns true if the user can comment to the existingPost

func (*User) CanDelete

func (user *User) CanDelete(message Content) bool

CanDelete returns true if user can delete the Message

func (*User) CanEdit

func (user *User) CanEdit(message Content) bool

CanEdit returns true if user can edit the Message

func (*User) CanLurk

func (user *User) CanLurk(message ExistingPost) bool

CanLurk returns true if the user haven't lurked the existingPost yet

func (*User) CanSee

func (user *User) CanSee(board Board) bool

CanSee returns true if the user can see the Board content

func (*User) ContactInfo

func (user *User) ContactInfo() *ContactInfo

ContactInfo returns a *ContactInfo struct

func (*User) Conversations

func (user *User) Conversations() (*[]Conversation, error)

Conversations returns all the private conversations done by the user

func (*User) Delete

func (user *User) Delete(message Content) error

Delete an existing message

func (*User) DeleteConversation

func (user *User) DeleteConversation(other uint64) error

DeleteConversation deletes the conversation of user with other user

func (*User) DeleteInterest

func (user *User) DeleteInterest(interest *Interest) error

DeleteInterest removes the specified interest (by its ID or its Value).

func (*User) Edit

func (user *User) Edit(message Content) error

Edit an existing message

func (*User) Follow

func (user *User) Follow(board Board) error

Follow creates a new "follow" relationship between the current user and another NERDZ board. The board could represent a NERDZ's project or another NERDZ's user.

func (*User) Followers

func (user *User) Followers() []*User

Followers returns a slice of User that are user's followers

func (*User) Friends

func (user *User) Friends() []*User

Friends returns the current user's friends

func (*User) Home

func (user *User) Home(options PostlistOptions) *[]Message

Home returns a slice of Post representing the user home. Posts are filtered by specified options.

func (*User) ID

func (user *User) ID() uint64

ID returns the user ID

func (*User) Info

func (user *User) Info() *Info

Info returns a *info struct

func (*User) Interests

func (user *User) Interests() (interests []string)

Interests returns a []string of user interests

func (*User) Language

func (user *User) Language() string

Language returns the user language

func (*User) LockPost

func (user *User) LockPost(post ExistingPost, users ...*User) (*[]Lock, error)

LockPost lockes the specified post. If users are present, indiidual notifications are disabled from the user presents in the users list.

func (*User) Lurk

func (user *User) Lurk(post ExistingPost) (Lurk, error)

Lurk lurkes the specified post by a specific user. An error is returned if the post isn't defined or if there are other errors returned by the DBMS

func (*User) NumericBlacklist

func (user *User) NumericBlacklist() (blacklist []uint64)

NumericBlacklist returns a slice containing the counters (IDs) of blacklisted user

func (*User) NumericBlacklisting

func (user *User) NumericBlacklisting() (blacklist []uint64)

NumericBlacklisting returns a slice containing the IDs of users that puts user (*User) in their blacklist

func (*User) NumericFollowers

func (user *User) NumericFollowers() (followers []uint64)

NumericFollowers returns a slice containing the IDs of User that are user's followers

func (*User) NumericFriends

func (user *User) NumericFriends() (friends []uint64)

NumericFriends returns a slice containing the IDs of Users that are user's friends (follows each other)

func (*User) NumericProjectFollowing

func (user *User) NumericProjectFollowing() (following []uint64)

NumericProjectFollowing returns a slice containing the IDs of Project that user (User *) is following

func (*User) NumericProjects

func (user *User) NumericProjects() (projects []uint64)

NumericProjects returns a slice containing the IDs of the projects owned by user

func (*User) NumericUserFollowing

func (user *User) NumericUserFollowing() (following []uint64)

NumericUserFollowing returns a slice containing the IDs of User that user (User *) is following

func (*User) NumericWhitelist

func (user *User) NumericWhitelist() []uint64

NumericWhitelist returns a slice containing the IDs of users that are in user whitelist

func (*User) NumericWhitelisting

func (user *User) NumericWhitelisting() (whitelisting []uint64)

NumericWhitelisting returns a slice containing thr IDs of users that whitelisted the user

func (*User) PersonalInfo

func (user *User) PersonalInfo() *PersonalInfo

PersonalInfo returns a *PersonalInfo struct

func (*User) Pms

func (user *User) Pms(otherUser uint64, options PmsOptions) (*[]PM, error)

Pms returns a slice of Pm, representing the list of the last messages exchanged with other users

func (*User) Postlist

func (user *User) Postlist(options PostlistOptions) *[]ExistingPost

Postlist returns the specified slice of post on the user board

func (*User) ProjectFollowing

func (user *User) ProjectFollowing() []*Project

ProjectFollowing returns a slice of Project that user (User *) is following

func (*User) ProjectHome

func (user *User) ProjectHome(options PostlistOptions) *[]ProjectPost

ProjectHome returns a slice of ProjectPost selected by options

func (*User) Projects

func (user *User) Projects() []*Project

Projects returns a slice of projects owned by the user

func (*User) Submit

func (user *User) Submit(message Content) error

Submit submits a Message

func (User) TableName

func (User) TableName() string

TableName returns the table name associated with the structure

func (*User) UnblacklistUser

func (user *User) UnblacklistUser(other *User) error

UnblacklistUser removes other user to the user blacklist

func (*User) Unbookmark

func (user *User) Unbookmark(post ExistingPost) error

Unbookmark the specified post by a specific user. An error is returned if the post isn't defined or if there are other errors returned by the DBMS

func (*User) Unfollow

func (user *User) Unfollow(board Board) error

Unfollow delete a "follow" relationship between the current user and another NERDZ board. The board could represent a NERDZ's project or another NERDZ's user.

func (*User) Unlock

func (user *User) Unlock(post ExistingPost, users ...*User) error

Unlock the specified post by a specific user. An error is returned if the post isn't defined or if there are other errors returned by the DBMS

func (*User) Unlurk

func (user *User) Unlurk(post ExistingPost) error

Unlurk the specified post by a specific user. An error is returned if the post isn't defined or if there are other errors returned by the DBMS

func (*User) UnwhitelistUser

func (user *User) UnwhitelistUser(other *User) error

UnwhitelistUser removes other user to the user whitelist

func (*User) UserFollowing

func (user *User) UserFollowing() []*User

UserFollowing returns a slice of User that user (User *) is following

func (*User) UserHome

func (user *User) UserHome(options PostlistOptions) *[]UserPost

UserHome returns a slice of UserPost specified by options

func (*User) Vote

func (user *User) Vote(message Content, vote int8) (Vote, error)

Vote express a positive/negative preference for a post or comment. Returns the vote if everything went ok

func (*User) Whitelist

func (user *User) Whitelist() []*User

Whitelist returns a slice of users that are in the user whitelist

func (*User) WhitelistUser

func (user *User) WhitelistUser(other *User) error

WhitelistUser add other user to the user whitelist

func (*User) Whitelisting

func (user *User) Whitelisting() []*User

Whitelisting returns a slice of users that whitelisted the user

type UserFollower

type UserFollower struct {
	From     uint64
	To       uint64
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	ToNotify bool
	Counter  uint64 `igor:"primary_key"`
}

UserFollower is the model for the relation followers

func (UserFollower) TableName

func (UserFollower) TableName() string

TableName returns the table name associated with the structure

type UserPost

type UserPost struct {
	Post
}

UserPost is the model for the relation posts

func NewUserPost

func NewUserPost(hpid uint64) (*UserPost, error)

NewUserPost returns the *UserPost with id hpid if exists. Returns error otherwise

func NewUserPostWhere

func NewUserPostWhere(description *UserPost) (post *UserPost, e error)

NewUserPostWhere returns the *UserPost fetching the first one that matches the description

func (*UserPost) Bookmarkers

func (post *UserPost) Bookmarkers() []*User

Bookmarkers returns a slice of users that bookmarked the post

func (*UserPost) Bookmarks

func (post *UserPost) Bookmarks() *[]Bookmark

Bookmarks returns a pointer to a slice of Bookmark

func (*UserPost) BookmarksCount

func (post *UserPost) BookmarksCount() (count uint8)

BookmarksCount returns the number of users that bookmarked the post

func (*UserPost) ClearDefaults

func (post *UserPost) ClearDefaults()

ClearDefaults set to the go's default values the fields with default sql values

func (*UserPost) Comments

func (post *UserPost) Comments(options CommentlistOptions) *[]ExistingComment

Comments returns the full comments list, or the selected range of comments Comments(options) returns the comment list, using selected options

func (*UserPost) CommentsCount

func (post *UserPost) CommentsCount() (count uint8)

CommentsCount returns the number of comment's post

func (*UserPost) ID

func (post *UserPost) ID() uint64

ID returns the User Post ID

func (*UserPost) IsClosed

func (post *UserPost) IsClosed() bool

IsClosed reuturns ture if the post is closed

func (*UserPost) IsEditable

func (post *UserPost) IsEditable() bool

IsEditable returns true if the post is editable

func (*UserPost) Language

func (post *UserPost) Language() string

Language returns the message language

func (*UserPost) Locks

func (post *UserPost) Locks() *[]Lock

Locks returns a pointer to a slice of Lock

func (*UserPost) Lurkers

func (post *UserPost) Lurkers() []*User

Lurkers returns a slice of users that are lurking the post

func (*UserPost) LurkersCount

func (post *UserPost) LurkersCount() (count uint8)

LurkersCount returns the number of users that are lurking the post

func (*UserPost) Lurks

func (post *UserPost) Lurks() *[]Lurk

Lurks returns a pointer to a slice of Lurk

func (*UserPost) NumericBookmarkers

func (post *UserPost) NumericBookmarkers() (bookmarkers []uint64)

NumericBookmarkers returns a slice of uint64 representing the ids of the users that bookmarked the post

func (*UserPost) NumericLurkers

func (post *UserPost) NumericLurkers() (lurkers []uint64)

NumericLurkers returns a slice of uint64 representing the ids of the users that lurked the post

func (*UserPost) NumericOwners

func (post *UserPost) NumericOwners() []uint64

NumericOwners returns a slice of ids of the owner of the posts (the ones that can perform actions)

func (*UserPost) NumericReference

func (post *UserPost) NumericReference() uint64

NumericReference returns the id of the recipient user

func (*UserPost) NumericSender

func (post *UserPost) NumericSender() uint64

NumericSender returns the id of the sender user

func (*UserPost) NumericType

func (*UserPost) NumericType() uint8

NumericType returns the numeric type of the post

func (*UserPost) Owners

func (post *UserPost) Owners() (ret []*User)

Owners returns a slice of *User representing the users who own the post

func (*UserPost) Reference

func (post *UserPost) Reference() Reference

Reference returns the recipient *User

func (*UserPost) Revisions

func (post *UserPost) Revisions() (modifications []string)

Revisions returns all the revisions of the message

func (*UserPost) RevisionsNumber

func (post *UserPost) RevisionsNumber() (count uint8)

RevisionsNumber returns the number of the revisions

func (*UserPost) Sender

func (post *UserPost) Sender() *User

Sender returns the sender *User

func (*UserPost) SetLanguage

func (post *UserPost) SetLanguage(language string) error

SetLanguage set the language of the post

func (*UserPost) SetReference

func (post *UserPost) SetReference(id uint64)

SetReference sets the destionation of the post: user ID

func (*UserPost) SetSender

func (post *UserPost) SetSender(id uint64)

SetSender sets the source of the post (the user ID)

func (*UserPost) SetText

func (post *UserPost) SetText(message string)

SetText set the text of the message

func (UserPost) TableName

func (UserPost) TableName() string

TableName returns the table name associated with the structure

func (*UserPost) Text

func (post *UserPost) Text() string

Text returns the post message

func (*UserPost) Type

func (*UserPost) Type() string

Type returns a string representing the post type

func (*UserPost) Votes

func (post *UserPost) Votes() *[]Vote

Votes returns a pointer to a slice of Vote

func (*UserPost) VotesCount

func (post *UserPost) VotesCount() (sum int)

VotesCount returns the post's votes value

type UserPostBookmark

type UserPostBookmark struct {
	Hpid    uint64
	From    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostBookmark is the model for the relation bookmarks

func (*UserPostBookmark) NumericReference

func (bookmark *UserPostBookmark) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostBookmark) NumericSender

func (bookmark *UserPostBookmark) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostBookmark) Reference

func (bookmark *UserPostBookmark) Reference() Reference

Reference returns the reference of the bookmark

func (*UserPostBookmark) Sender

func (bookmark *UserPostBookmark) Sender() (user *User)

Sender returns the User that casted the bookmark

func (UserPostBookmark) TableName

func (UserPostBookmark) TableName() string

TableName returns the table name associated with the structure

type UserPostComment

type UserPostComment struct {
	Hcid     uint64 `igor:"primary_key"`
	Hpid     uint64
	From     uint64
	To       uint64
	Message  string
	Lang     string
	Time     time.Time `sql:"default:(now() at time zone 'utc')"`
	Editable bool      `sql:"default:true"`
}

UserPostComment is the model for the relation comments

func NewUserPostComment

func NewUserPostComment(hcid uint64) (comment *UserPostComment, e error)

NewUserPostComment initializes a UserPostComment struct

func NewUserPostCommentWhere

func NewUserPostCommentWhere(description *UserPostComment) (comment *UserPostComment, e error)

NewUserPostCommentWhere returns the *UserPostComment fetching the first one that matches the description

func (*UserPostComment) ClearDefaults

func (comment *UserPostComment) ClearDefaults()

ClearDefaults set to the go's default values the fields with default sql values

func (*UserPostComment) ID

func (comment *UserPostComment) ID() uint64

ID returns the UserPostComment ID

func (*UserPostComment) IsEditable

func (comment *UserPostComment) IsEditable() bool

IsEditable returns true if the comment is editable

func (*UserPostComment) Language

func (comment *UserPostComment) Language() string

Language returns the message language

func (*UserPostComment) NumericOwners

func (comment *UserPostComment) NumericOwners() []uint64

NumericOwners returns a slice of ids of the owner of the comment (the ones that can perform actions)

func (*UserPostComment) NumericReference

func (comment *UserPostComment) NumericReference() uint64

NumericReference returns the id of the recipient Post

func (*UserPostComment) NumericSender

func (comment *UserPostComment) NumericSender() uint64

NumericSender returns the id of the sender user

func (*UserPostComment) Owners

func (comment *UserPostComment) Owners() []*User

Owners returns a slice of *User representing the users who own the comment

func (*UserPostComment) Post

func (comment *UserPostComment) Post() (ExistingPost, error)

Post returns the ExistingPost struct to which the comment is related

func (*UserPostComment) Reference

func (comment *UserPostComment) Reference() Reference

Reference returns the recipient *Post

func (*UserPostComment) Revisions

func (comment *UserPostComment) Revisions() (modifications []string)

Revisions returns all the revisions of the message

func (*UserPostComment) RevisionsNumber

func (comment *UserPostComment) RevisionsNumber() (count uint8)

RevisionsNumber returns the number of the revisions

func (*UserPostComment) Sender

func (comment *UserPostComment) Sender() *User

Sender returns the sender *User

func (*UserPostComment) SetLanguage

func (comment *UserPostComment) SetLanguage(language string) error

SetLanguage set the language of the comment

func (*UserPostComment) SetReference

func (comment *UserPostComment) SetReference(id uint64)

SetReference sets the destination of the comment (the post ID)

func (*UserPostComment) SetSender

func (comment *UserPostComment) SetSender(id uint64)

SetSender sets the source of the comment (the user ID)

func (*UserPostComment) SetText

func (comment *UserPostComment) SetText(message string)

SetText set the text of the message

func (UserPostComment) TableName

func (UserPostComment) TableName() string

TableName returns the table name associated with the structure

func (*UserPostComment) Text

func (comment *UserPostComment) Text() string

Text returns the post message

func (*UserPostComment) Votes

func (comment *UserPostComment) Votes() *[]Vote

Votes returns a pointer to a slice of Vote

func (*UserPostComment) VotesCount

func (comment *UserPostComment) VotesCount() (sum int)

Votes returns the post's votes value

type UserPostCommentRevision

type UserPostCommentRevision struct {
	Hcid    uint64
	Message string
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	RevNo   int8
	Counter uint64 `igor:"primary_key"`
}

UserPostCommentRevision is the model for the relation comments_revisions

func (UserPostCommentRevision) TableName

func (UserPostCommentRevision) TableName() string

TableName returns the table name associated with the structure

type UserPostCommentVote

type UserPostCommentVote struct {
	Hcid    uint64
	From    uint64
	Vote    int8
	Counter uint64 `igor:"primary_key"`
}

UserPostCommentVote is the model for the relation groups_comment_thumbs

func (*UserPostCommentVote) NumericReference

func (vote *UserPostCommentVote) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostCommentVote) NumericSender

func (vote *UserPostCommentVote) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostCommentVote) Reference

func (vote *UserPostCommentVote) Reference() Reference

Reference returns the reference of the vote

func (*UserPostCommentVote) Sender

func (vote *UserPostCommentVote) Sender() (user *User)

Sender returns the User that casted the vote

func (UserPostCommentVote) TableName

func (UserPostCommentVote) TableName() string

TableName returns the table name associated with the structure

func (*UserPostCommentVote) Value

func (vote *UserPostCommentVote) Value() int8

Value returns the vote's value

type UserPostCommentsNotify

type UserPostCommentsNotify struct {
	From    uint64
	To      uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostCommentsNotify is the model for the relation comments_notify

func (UserPostCommentsNotify) TableName

func (UserPostCommentsNotify) TableName() string

TableName returns the table name associated with the structure

type UserPostLock

type UserPostLock struct {
	User    uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostLock is the model for the relation posts_no_notify

func (*UserPostLock) NumericReference

func (lock *UserPostLock) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostLock) NumericSender

func (lock *UserPostLock) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostLock) Reference

func (lock *UserPostLock) Reference() Reference

Reference returns the reference of the lurk

func (*UserPostLock) Sender

func (lock *UserPostLock) Sender() (user *User)

Sender returns the User that casted the lock

func (UserPostLock) TableName

func (UserPostLock) TableName() string

TableName returns the table name associated with the structure

type UserPostLurk

type UserPostLurk struct {
	Hpid    uint64
	From    uint64
	To      uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostLurk is the model for the relation lurkers

func (*UserPostLurk) NumericReference

func (lurk *UserPostLurk) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostLurk) NumericSender

func (lurk *UserPostLurk) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostLurk) Reference

func (lurk *UserPostLurk) Reference() Reference

Reference returns the reference of the lurk

func (*UserPostLurk) Sender

func (lurk *UserPostLurk) Sender() (user *User)

Sender returns the User that casted the lurk

func (UserPostLurk) TableName

func (UserPostLurk) TableName() string

TableName returns the table name associated with the structure

type UserPostRevision

type UserPostRevision struct {
	Hpid    uint64
	Message string
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	RevNo   uint16
	Counter uint64 `igor:"primary_key"`
}

UserPostRevision is the model for the relation posts_revisions

func (UserPostRevision) TableName

func (UserPostRevision) TableName() string

TableName returns the table name associated with the structure

type UserPostUserLock

type UserPostUserLock struct {
	From    uint64
	To      uint64
	Hpid    uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostUserLock is the model for the relation comments_no_notify

func (*UserPostUserLock) NumericReference

func (lock *UserPostUserLock) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostUserLock) NumericSender

func (lock *UserPostUserLock) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostUserLock) Reference

func (lock *UserPostUserLock) Reference() Reference

Reference returns the reference of the lurk

func (*UserPostUserLock) Sender

func (lock *UserPostUserLock) Sender() (user *User)

Sender returns the User that casted the lock

func (UserPostUserLock) TableName

func (UserPostUserLock) TableName() string

TableName returns the table name associated with the structure

type UserPostVote

type UserPostVote struct {
	Hpid    uint64
	From    uint64
	To      uint64
	Vote    int8
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

UserPostVote is the model for the relation votes

func (*UserPostVote) NumericReference

func (vote *UserPostVote) NumericReference() uint64

NumericReference returns the numeric ID of the reference

func (*UserPostVote) NumericSender

func (vote *UserPostVote) NumericSender() uint64

NumericSender returns the ID of the Sender

func (*UserPostVote) Reference

func (vote *UserPostVote) Reference() Reference

Reference returns the reference of the vote

func (*UserPostVote) Sender

func (vote *UserPostVote) Sender() (user *User)

Sender returns the User that casted the vote

func (UserPostVote) TableName

func (UserPostVote) TableName() string

TableName returns the table name associated with the structure

func (*UserPostVote) Value

func (vote *UserPostVote) Value() int8

Value returns the vote's value

type Vote

type Vote interface {
	Value() int8
	// contains filtered or unexported methods
}

Vote is a generic interface to represent a vote

type Whitelist

type Whitelist struct {
	From    uint64
	To      uint64
	Time    time.Time `sql:"default:(now() at time zone 'utc')"`
	Counter uint64    `igor:"primary_key"`
}

Whitelist is the model for the relation whitelist

func (Whitelist) TableName

func (Whitelist) TableName() string

TableName returns the table name associated with the structure

Jump to

Keyboard shortcuts

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