Documentation ¶
Overview ¶
database wraps the appengine/datastore to provide support to Golb
Index ¶
- Variables
- func Delete(title string, ctx appengine.Context) error
- func Get(key string, ctx appengine.Context) (*post.Post, error)
- func Put(data *post.Post, isUpdate bool, ctx appengine.Context) error
- func Query(offset, limit int, encodedCursor string, ctx appengine.Context) ([]post.Post, bool, string, error)
- type PostContent
- type PostItem
Constants ¶
This section is empty.
Variables ¶
var ErrCannotUseCursor = errors.New("Fail to decode this cursor")
var ErrPostExists = errors.New("Post with this title exists in datastore")
var ErrPostNotExists = errors.New("Post with this title doesn't exist in datastore")
Functions ¶
func Get ¶
Get returns a post from datastore. If the key is item key, it returns item part if the key is content key, it returns item along with content part if the key is contentmd key, it returns item along with original part
func Put ¶
Put stored a post into datastore. It split original data into 3 parts: PostItem, Content with HTML, Original Markdown Content. Then store them in a transaction if isUpdate is true, then it is a update to original post. otherwise it is a new post.
func Query ¶
func Query(offset, limit int, encodedCursor string, ctx appengine.Context) ([]post.Post, bool, string, error)
Query first jumps 'offset' posts, then return 'limit' posts, along with a boolean value to denote if database has more posts, a string to denote cursor for that query. Based on GAE document, offset has its own cost, so App should store this value, and use it for the same query next time. Otherwise, use empty string "" as encodedCursor, this function will do query with offset (has more workload)
Types ¶
type PostContent ¶
type PostContent struct {
Content string `datastore:",noindex"`
}