示例#1
0
文件: datastore.go 项目: yokano/tango
/**
 * データストアの単語をすべて削除する
 * ajaxから呼び出すためのAPI
 */
func clear(w http.ResponseWriter, r *http.Request) {
	var c appengine.Context
	var u *user.User
	var keys []*datastore.Key
	var err error
	var query *datastore.Query
	var count int
	var entities []Entity

	c = appengine.NewContext(r)
	u = user.Current(c)
	query = datastore.NewQuery("words").Filter("UserID =", u.ID)
	count, err = query.Count(c)
	Check(c, err)
	entities = make([]Entity, count)
	keys, err = query.GetAll(c, &entities)
	Check(c, err)
	err = datastore.DeleteMulti(c, keys)
	Check(c, err)
}
示例#2
0
文件: query.go 项目: biggtfish/goread
// Count returns the number of results for the query.
func (g *Goon) Count(q *datastore.Query) (int, error) {
	return q.Count(g.Context)
}
示例#3
0
func GetCount(c appengine.Context, q *datastore.Query) (int, error) {
	return q.Count(c)
}