data

package
v0.0.0-...-9fe20ad Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FollowStore = new(Follows)
View Source
var LikeStore = new(Likes)
View Source
var PostStore = new(Posts)
View Source
var ProfileStore = new(Profiles)
View Source
var UserStore = new(Users)

Functions

func NewUuid

func NewUuid() string

Types

type DataType

type DataType interface {
	GetID()
	SetID()
	SaveToStore()
}

type Follow

type Follow struct {
	User    int64 `json:"user"`
	Follows int64 `json:"follows"`
}

follow type for a follow Instance

func (*Follow) SaveToStore

func (f *Follow) SaveToStore()

SaveToStore saves the follow to the given dB store

type Follows

type Follows struct {
	Follows []Follow `json:"follow"`
}

follows type for Users List

func (*Follows) AddDbList

func (f *Follows) AddDbList(follow *Follow)

AddDbList adds a new follow to follows.follows

func (*Follows) CommitDb

func (f *Follows) CommitDb()

CommitDb writes follows.follows to the file

func (*Follows) DeleteFollow

func (f *Follows) DeleteFollow(userId, follows int64) error

func (*Follows) GetByUserAndFollows

func (f *Follows) GetByUserAndFollows(userId, follows int64) *Follow

get follow relation between 2 users

func (*Follows) GetFollowers

func (f *Follows) GetFollowers(id int64) []Follow

followers of id

func (*Follows) GetFollowingCount

func (f *Follows) GetFollowingCount(userId int64) int64

func (*Follows) GetFollowsCount

func (f *Follows) GetFollowsCount(userId int64) int64

func (*Follows) GetfollowByUser

func (f *Follows) GetfollowByUser(id int64) []Follow

id is following

func (*Follows) ReadFromDb

func (f *Follows) ReadFromDb() *Follows

ReadFromDb updates follows.follows from the file

type Like

type Like struct {
	Post   int64 `json:"post"`
	Author int64 `json:"author"`
}

like type for a like Instance

func (*Like) SaveToStore

func (l *Like) SaveToStore()

SaveToStore saves the like to the given dB store

type Likes

type Likes struct {
	Likes []Like `json:"like"`
}

likes type for Users List

func (*Likes) AddDbList

func (l *Likes) AddDbList(like *Like)

AddDbList adds a new like to likes.likes

func (*Likes) CommitDb

func (l *Likes) CommitDb()

CommitDb writes likes.likes to the file

func (*Likes) DeleteLike

func (l *Likes) DeleteLike(postId, authorId int64) error

func (*Likes) GetByPostAndAuthor

func (l *Likes) GetByPostAndAuthor(postId, authorId int64) *Like

func (*Likes) GetLikesCount

func (l *Likes) GetLikesCount(postId int64) int64

func (*Likes) GetLikesForPost

func (l *Likes) GetLikesForPost(postid int64) []Like

func (*Likes) GetlikeByAuthor

func (l *Likes) GetlikeByAuthor(id int64) []Like

func (*Likes) ReadFromDb

func (l *Likes) ReadFromDb() *Likes

ReadFromDb updates likes.likes from the file

type Post

type Post struct {
	ID        int64  `json:"id"`
	Title     string `json:"title"`
	Created   int64  `json:"created"`
	Author    int64  `json:"author"`
	ParentId  int64  `json:"parentid"`
	Children  []Post `json:"children"`
	Media     string `json:"media"`
	RezweetId int64  `json:"rezweetId"`
}

Post type for a Post Instance

func (*Post) GetID

func (p *Post) GetID() int64

GetID returns ID of the Post

func (*Post) SaveToStore

func (p *Post) SaveToStore()

SaveToStore saves the Post to the given dB store

func (*Post) SetID

func (p *Post) SetID(id int64)

SetID sets ID of the Post

type Posts

type Posts struct {
	Posts []Post `json:"posts"`
}

Posts type for Users List

func (*Posts) AddDbList

func (p *Posts) AddDbList(post *Post)

AddDbList adds a new Post to Posts.Posts

func (*Posts) CommitDb

func (p *Posts) CommitDb()

CommitDb writes Posts.Posts to the file

func (*Posts) GetByID

func (p *Posts) GetByID(id int64) *Post

GetByID returns Post with given ID

func (*Posts) GetPostChilds

func (p *Posts) GetPostChilds(id int64) []Post

func (*Posts) GetPostWithChilds

func (p *Posts) GetPostWithChilds(id int64) *Post

func (*Posts) GetPosts

func (p *Posts) GetPosts() []Post

func (*Posts) GetPostsByUser

func (p *Posts) GetPostsByUser(userid int64) []Post

func (*Posts) GetUserFeed

func (p *Posts) GetUserFeed(userId int64, following []int64) []Post

func (*Posts) NewID

func (p *Posts) NewID() int64

NewID returns new ID for the new Post

func (*Posts) ReadFromDb

func (p *Posts) ReadFromDb() *Posts

ReadFromDb updates Posts.Posts from the file

type Profile

type Profile struct {
	UserId      int64  `json:"userId"`
	DisplayName string `json:"displayName"`
	Birthday    string `json:"birthday"`
	Gender      int    `json:"gender"`
}

func (*Profile) GetID

func (p *Profile) GetID() int64

GetID returns ID of the user

func (*Profile) SaveToStore

func (p *Profile) SaveToStore()

SaveToStore saves the user to the store

type Profiles

type Profiles struct {
	Profiles []*Profile `json:"profiles"`
}

func (*Profiles) AddDbList

func (p *Profiles) AddDbList(profile *Profile)

AddDbList adds a User type to Users.Users

func (*Profiles) CommitDb

func (p *Profiles) CommitDb()

CommitDb writes the current database instance to the file

func (*Profiles) GetByID

func (p *Profiles) GetByID(id int64) *Profile

GetByID returns a user with given ID from the database instance

func (*Profiles) ReadFromDb

func (p *Profiles) ReadFromDb() *Profiles

ReadFromDb Updates the database Instance from the file

func (*Profiles) UpdateProfiles

func (p *Profiles) UpdateProfiles(id int64, profile *Profile) *Profile

GetByID returns a user with given ID from the database instance

type Store

type Store struct {
	Name string
	Path string
}

func New

func New(storeName string) *Store

func (*Store) GetContent

func (s *Store) GetContent() []byte

func (*Store) GetFilePath

func (s *Store) GetFilePath() string

func (*Store) SetFilePath

func (s *Store) SetFilePath(pathValue string)

func (*Store) Write

func (s *Store) Write(data []byte)

type User

type User struct {
	ID       int64  `json:"id"`
	Username string `json:"username"`
	Password string `json:"-"`
	Created  int64  `json:"created"`
}

User type for a single user instance

func (*User) GetID

func (p *User) GetID() int64

GetID returns ID of the user

func (*User) SaveToStore

func (p *User) SaveToStore()

SaveToStore saves the user to the store

func (*User) SetID

func (p *User) SetID(id int64)

SetID sets ID of the user

type Users

type Users struct {
	Users []User `json:"users"`
}

Users type for Users List

func (*Users) AddDbList

func (p *Users) AddDbList(user *User) int64

AddDbList adds a User type to Users.Users

func (*Users) CommitDb

func (p *Users) CommitDb()

CommitDb writes the current database instance to the file

func (*Users) GetByID

func (p *Users) GetByID(id int64) *User

GetByID returns a user with given ID from the database instance

func (*Users) GetByUsername

func (p *Users) GetByUsername(username string) *User

GetByID returns a user with given ID from the database instance

func (*Users) NewID

func (p *Users) NewID() int64

NewID returns a new ID for creating new database object

func (*Users) ReadFromDb

func (p *Users) ReadFromDb() *Users

ReadFromDb Updates the database Instance from the file

Jump to

Keyboard shortcuts

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