當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gorethink.Asc函數代碼示例

本文整理匯總了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)
}
開發者ID:EntropyWorks,項目名稱:enforcer,代碼行數:26,代碼來源:node_endpoint.go

示例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()
}
開發者ID:yetis-br,項目名稱:travelPlanning,代碼行數:26,代碼來源:trip.go

示例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
}
開發者ID:atassumer,項目名稱:shipyard,代碼行數:11,代碼來源:manager.go

示例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
}
開發者ID:rbramwell,項目名稱:shipyard,代碼行數:11,代碼來源:manager.go

示例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
}
開發者ID:rbramwell,項目名稱:shipyard,代碼行數:11,代碼來源:manager.go

示例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
}
開發者ID:nfoonf,項目名稱:shipyard,代碼行數:11,代碼來源:manager.go

示例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
}
開發者ID:nfoonf,項目名稱:shipyard,代碼行數:11,代碼來源:manager.go

示例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
}
開發者ID:carriercomm,項目名稱:dialogue-1,代碼行數:17,代碼來源:db.go

示例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
}
開發者ID:carriercomm,項目名稱:dialogue-1,代碼行數:17,代碼來源:db.go

示例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()
}
開發者ID:yetis-br,項目名稱:travelPlanning,代碼行數:20,代碼來源:place.go

示例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
}
開發者ID:sporto,項目名稱:kic,代碼行數:20,代碼來源:adjust_all.go

示例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",
	})
}
開發者ID:ramigg,項目名稱:GoRethink_TodoDemo,代碼行數:21,代碼來源:server.go

示例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)
}
開發者ID:megaserg,項目名稱:reactchat,代碼行數:22,代碼來源:handlers.go

示例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(&regs); 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
}
開發者ID:nfoonf,項目名稱:shipyard,代碼行數:23,代碼來源:manager.go

示例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)
}
開發者ID:sporto,項目名稱:kic,代碼行數:23,代碼來源:accounts.go


注:本文中的github.com/dancannon/gorethink.Asc函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。