本文整理汇总了Golang中github.com/dancannon/gorethink.Asc函数的典型用法代码示例。如果您正苦于以下问题:Golang Asc函数的具体用法?Golang Asc怎么用?Golang Asc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Asc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Nodes
// Returns a complete list of all nodes
func (s *HTTPServer) Nodes(w http.ResponseWriter, req *http.Request) {
instructions := []Machine{}
// Fetch all the items from the database
rows, err := r.Table(tableIpxe).OrderBy(r.Asc("Created")).Run(session)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// Scan each row into a TodoItem instance and then add this to the list
for rows.Next() {
var instruction Machine
err := rows.Scan(&instruction)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
instructions = append(instructions, instruction)
}
renderHtml(w, "enforcer", instructions)
}
示例2: GetAllTrips
//GetAllTrips returns all Trips for the loged user
func (t *Trips) GetAllTrips(w rest.ResponseWriter, r *rest.Request) {
trips := []Trip{}
//table := t.TableName
// Fetch all the items from the database
res, err := rethink.Table(tableName).OrderBy(rethink.Asc("Created")).Run(t.Conn)
if err != nil {
rest.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = res.All(&trips)
//Include total places in the
for _, trip := range trips {
trip.TotalPlaces = len(trip.Places)
}
if err != nil {
rest.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.WriteJson(&trips)
res.Close()
}
示例3: Accounts
func (m *Manager) Accounts() ([]*shipyard.Account, error) {
res, err := r.Table(tblNameAccounts).OrderBy(r.Asc("username")).Run(m.session)
if err != nil {
return nil, err
}
var accounts []*shipyard.Account
if err := res.All(&accounts); err != nil {
return nil, err
}
return accounts, nil
}
示例4: Roles
func (m *Manager) Roles() ([]*shipyard.Role, error) {
res, err := r.Table(tblNameRoles).OrderBy(r.Asc("name")).Run(m.session)
if err != nil {
return nil, err
}
roles := []*shipyard.Role{}
if err := res.All(&roles); err != nil {
return nil, err
}
return roles, nil
}
示例5: Extensions
func (m *Manager) Extensions() ([]*shipyard.Extension, error) {
res, err := r.Table(tblNameExtensions).OrderBy(r.Asc("name")).Run(m.session)
if err != nil {
return nil, err
}
exts := []*shipyard.Extension{}
if err := res.All(&exts); err != nil {
return nil, err
}
return exts, nil
}
示例6: Accounts
func (m DefaultManager) Accounts() ([]*auth.Account, error) {
res, err := r.Table(tblNameAccounts).OrderBy(r.Asc("username")).Run(m.session)
if err != nil {
return nil, err
}
accounts := []*auth.Account{}
if err := res.All(&accounts); err != nil {
return nil, err
}
return accounts, nil
}
示例7: WebhookKeys
func (m DefaultManager) WebhookKeys() ([]*dockerhub.WebhookKey, error) {
res, err := r.Table(tblNameWebhookKeys).OrderBy(r.Asc("image")).Run(m.session)
if err != nil {
return nil, err
}
keys := []*dockerhub.WebhookKey{}
if err := res.All(&keys); err != nil {
return nil, err
}
return keys, nil
}
示例8: GetTopics
func (s *Rethinkdb) GetTopics() ([]*dialogue.Topic, error) {
var topics []*dialogue.Topic
res, err := rdb.Table(TOPIC_TABLE).OrderBy(rdb.Asc("Created")).Run(s.session)
if err != nil {
log.Errorf("Unable to get topics from db: %s", err)
return nil, err
}
for res.Next() {
var t *dialogue.Topic
if err := res.Scan(&t); err != nil {
log.Errorf("Unable to deserialize topic from db: %s", err)
return nil, err
}
topics = append(topics, t)
}
return topics, nil
}
示例9: GetPosts
func (s *Rethinkdb) GetPosts(topicId string) ([]*dialogue.Post, error) {
var posts []*dialogue.Post
res, err := rdb.Table(POST_TABLE).OrderBy(rdb.Asc("Created")).Run(s.session)
if err != nil {
log.Errorf("Unable to get posts from db: %s", err)
return nil, err
}
for res.Next() {
var p *dialogue.Post
if err := res.Scan(&p); err != nil {
log.Errorf("Unable to deserialize post from db: %s", err)
return nil, err
}
posts = append(posts, p)
}
return posts, nil
}
示例10: GetAllPlaces
//GetAllPlaces returns all Places for the loged user
func (t *Places) GetAllPlaces(w rest.ResponseWriter, r *rest.Request) {
places := []Place{}
//table := t.TableName
// Fetch all the items from the database
res, err := rethink.Table(tableName).OrderBy(rethink.Asc("Created")).Run(t.Conn)
if err != nil {
rest.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = res.All(&places)
if err != nil {
rest.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.WriteJson(&places)
res.Close()
}
示例11: Run
func (serv *AdjustAllServ) Run(dbSession *r.Session) (err error) {
// Fetch all the items from the database
rows, err := r.Table("accounts").OrderBy(r.Asc("CreatedAt")).Run(dbSession)
for rows.Next() {
var account models.Account
err := rows.Scan(&account)
if err != nil {
fmt.Println("err", err)
break
}
_, _, err = serv.adjustBalanceServ.Run(dbSession, account)
if err != nil {
fmt.Println("err", err)
break
}
}
return
}
示例12: indexHandler
func indexHandler(w http.ResponseWriter, req *http.Request) {
items := []TodoItem{}
// Fetch all the items from the database
res, err := r.Table("items").OrderBy(r.Asc("Created")).Run(session)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
err = res.All(&items)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
renderTemplate(w, "index", map[string]interface{}{
"Items": items,
"Route": "all",
})
}
示例13: subscribeMessage
func subscribeMessage(client *Client, data interface{}) {
eventData := data.(map[string]interface{})
val, ok := eventData["channelId"]
if !ok {
return
}
channelId, ok := val.(string)
if !ok {
return
}
cursor, err := r.Table("message").
OrderBy(r.OrderByOpts{Index: r.Asc("createdAt")}).
Filter(r.Row.Field("channelId").Eq(channelId)).
Changes(r.ChangesOpts{IncludeInitial: true}).
Run(client.session)
if err != nil {
client.send <- SocketMessage{"error", err.Error()}
return
}
createSubscription(cursor, client, "message", MessageStop)
}
示例14: Registries
func (m DefaultManager) Registries() ([]*shipyard.Registry, error) {
res, err := r.Table(tblNameRegistries).OrderBy(r.Asc("name")).Run(m.session)
if err != nil {
return nil, err
}
regs := []*shipyard.Registry{}
if err := res.All(®s); err != nil {
return nil, err
}
registries := []*shipyard.Registry{}
for _, r := range regs {
reg, err := shipyard.NewRegistry(r.ID, r.Name, r.Addr)
if err != nil {
return nil, err
}
registries = append(registries, reg)
}
return registries, nil
}
示例15: ReadMany
func (c *Accounts) ReadMany(ctx context.Context) (err error) {
var accounts []models.Account
rows, err := r.Table("accounts").OrderBy(r.Asc("CreatedAt")).Run(c.DbSession)
rows.Scan(&accounts)
for rows.Next() {
var account models.Account
err = rows.Scan(&account)
if err != nil {
return
}
accounts = append(accounts, account)
}
if err != nil {
log.Fatal(err)
return goweb.Respond.WithStatus(ctx, http.StatusNotFound)
}
return goweb.API.RespondWithData(ctx, accounts)
}