Documentation ¶
Index ¶
- Variables
- type Comment
- type DB
- func (d *DB) FetchNPosts(ctx context.Context, n int) ([]*Post, error)
- func (d *DB) FetchPost(ctx context.Context, postid string) (*Post, error)
- func (d *DB) FetchPostsFromID(ctx context.Context, id, limit int, prop string) ([]*Post, error)
- func (d *DB) LikePost(ctx context.Context, postid string, deviceid string) error
- func (d *DB) RegisterDeviceID(ctx context.Context, deviceid string, hash string, t time.Duration) error
- func (d *DB) Report(ctx context.Context, postid, deviceid, reason string) error
- func (d *DB) SubmitPost(ctx context.Context, p *Post) error
- func (d *DB) VerifyDeviceID(ctx context.Context, deviceid string) (string, error)
- type IDB
- type Like
- type Post
- type PostMeta
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidPostID = "INVALID_POST_ID" ErrAlreadyLiked = "ALREADY_LIKED" )
View Source
var ( // ErrInvalidData is sent when a value in request is invalid ErrInvalidData = "INVALID_DATA" // ErrNotRegistered is sent when a deviceid is not registered ErrNotRegistered = "NOT_REGISTERED" )
Functions ¶
This section is empty.
Types ¶
type DB ¶
func (*DB) FetchNPosts ¶
FetchNPosts takes an integer and returns the most recent N posts
func (*DB) FetchPostsFromID ¶
FetchPostsFromID fetches a number of posts before or after the specified id
func (*DB) LikePost ¶
LikePost adds a new entry in likes table containing details like deviceid and postid. When complete details of a post are requested, We'll have to count all the entries containing specified postid.
func (*DB) RegisterDeviceID ¶
func (d *DB) RegisterDeviceID(ctx context.Context, deviceid string, hash string, t time.Duration) error
RegisterDeviceID takes a device id and a hash and saves it in database
func (*DB) SubmitPost ¶
SubmitPost takes a Post, puts it into the database and returns the postid
type IDB ¶
type IDB interface { FetchNPosts(ctx context.Context, n int) ([]*Post, error) FetchPostsFromID(ctx context.Context, id, limit int, prop string) ([]*Post, error) LikePost(ctx context.Context, postid, deviceid string) error Report(ctx context.Context, postid, deviceid, reason string) error SubmitPost(ctx context.Context, p *Post) error // Authentication related endpoints VerifyDeviceID(ctx context.Context, deviceid string) (string, error) RegisterDeviceID(ctx context.Context, deviceid, hash string, t time.Duration) error }
IDB interface defines all the database operations used by the application.
Click to show internal directories.
Click to hide internal directories.