Documentation ¶
Overview ¶
post.go Structures for rest server
Index ¶
Constants ¶
View Source
const API_VERSION = "1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comment ¶
type Comment struct { Id uint64 `db:"notnull, primarykey, autoincrement"` PostId uint64 `db:"notnull, index:idx_foreign_key_postid, uniqueindex:idx_webcomment"` // points to post.id WebCommentId string `db:"enforcenotnull, size:32, uniqueindex:idx_webcomment"` WebParentId string `db:"size:32"` CommentDate time.Time `db:"notnull"` User string `db:"size:64"` Score int `db:"notnull"` Body string `db:"name:CommentBody, type:mediumtext"` //size:16383"` ParseComplete bool `db:"-"` // ignore this field when storing with gorp Err error `db:"-"` // ignore this field when storing with gorp }
holds a single comment bound to a post
func NewComment ¶
func NewComment() Comment
func (*Comment) GetCommentDate ¶
func (*Comment) SetCommentDate ¶
Set the data a post was posted - if it cannot be parsed use the current datetime
func (*Comment) X_PreUpdate ¶
func (c *Comment) X_PreUpdate(s gorp.SqlExecutor) error
type ErrorDomain ¶
Item in an array of errors
type ErrorResponse ¶
type ErrorResponse struct { ApiVersion string `json:"apiVersion"` ErrorStruct struct { Code uint32 `json:"code"` Message string `json:"message"` XErrors []ErrorDomain `json:"errors"` } `json:"error"` }
The error structure to send back as JSON
func (*ErrorResponse) Append ¶
func (e *ErrorResponse) Append(ed ErrorDomain)
type Post ¶
type Post struct { Id uint64 `db:"notnull, PID, primarykey, autoincrement"` Created time.Time `db:"notnull"` PostDate time.Time `db:"notnull"` Site string `db:"name: PostSite, enforcenotnull, size:50, index:idx_site"` Thumbnail string `db:"-", json:"thumbnail"` WebPostId string `db:"enforcenotnull, size:32, uniqueindex:idx_webpost"` Score int `db:"notnull"` Title string `gorp:"notnull, size: 512"` Url string `db:"notnull, size:1024"` User string `db:"index:idx_user, size:64"` PostSub string `db:"index:idx_user, size:128"` Ignored int `gorp:"ignorefield"` UserIP string `db:"notnull, index:idx_user, size:16"` BodyType string `gorp:"notnull, size:64"` Body string `db:"name:PostBody, type:mediumtext"` Err error `db:"-"` // ignore this field when storing with gorp Comments []Comment `db:"relation:PostId"` // will create a table Comment as a detail table with foreignkey PostId // if you want a different name just issue a: table = dbmap.AddTableWithName(post.Comment{}, "comments_embedded_test") // after: table := dbmap.AddTableWithName(post.Post{}, "posts_embedded_test") // but before: dbmap.CreateTablesIfNotExists() CommentParseErrors []Comment `db:"-"` CommentCount uint64 }
Post holds a single post You can use ether db or gorp as tag
func (*Post) SetPostDate ¶
Set the date a post was posted - if it cannot be parsed use the current datetime
func (*Post) X_PreUpdate ¶
func (p *Post) X_PreUpdate(s gorp.SqlExecutor) error
implement the PreInsert and PreUpdate hooks
type PostSubThumbnail ¶
type PostSubThumbnail struct { Id uint64 `gorp:"notnull, primarykey, autoincrement"` Name string `gorp:"notnull, size: 128, uniqueindex:idx_post_thumbnail"` Url string `db:"notnull, size:1024"` }
Post sub image information struct
type Posts ¶
type Posts struct { ApiVersion string `json:"apiVersion"` RequestDuration int64 RequestErrorCode int RequestErrorMsg string Posts []*Post }
Posts holds a slice of Post
type User ¶
type User struct { Id uint64 `gorp:"notnull, primarykey, autoincrement"` Name string `gorp:"notnull, size: 64, uniqueindex:idx_user_name"` Password string `gorp:"size: 32"` Level int32 Group int32 Created time.Time `gorp:"notnull"` LastPost time.Time LastLogin time.Time Activity uint64 Avatar string `gorp:"size: 255"` Signature string `gorp:"size: 512"` Likes uint32 Hates uint32 }
User information struct
Click to show internal directories.
Click to hide internal directories.