Пример #1
0
func (c *Connection) Search(userID string, params martini.Params, query string) (response []interface{}, err error) {
	page, _ := strconv.ParseInt(params["page"], 10, 16)
	err = rethinkgo.Db("magnet").Table("bookmarks").Filter(rethinkgo.Row.Attr("Title").Match("(?i)" + query).And(rethinkgo.Row.Attr("User").Eq(userID))).OrderBy(rethinkgo.Desc("Created")).Skip(50 * page).Limit(50).Run(c.session).All(&response)
	return response, err
}
Пример #2
0
func (c *Connection) GetTag(userID string, params martini.Params) (response []interface{}, err error) {
	page, _ := strconv.ParseInt(params["page"], 10, 16)
	err = rethinkgo.Db("magnet").Table("bookmarks").Filter(rethinkgo.Row.Attr("User").Eq(userID).And(rethinkgo.Row.Attr("Tags").Contains(params["tag"]))).OrderBy(rethinkgo.Desc("Created")).Skip(50 * page).Limit(50).Run(c.session).All(&response)
	return response, err
}
Пример #3
0
func (c *Connection) GetBookmarks(userID string, page int64) ([]Bookmark, error) {
	var bookmarks []Bookmark
	err := rethinkgo.Db("magnet").Table("bookmarks").Filter(rethinkgo.Row.Attr("User").Eq(userID)).OrderBy(rethinkgo.Desc("Created")).Skip(50 * page).Limit(50).Run(c.session).All(&bookmarks)
	return bookmarks, err
}