コード例 #1
0
ファイル: circle.go プロジェクト: jmadan/go-msgstory
func GetCircleMembers(circleName string) []string {
	var circleMembers []string
	searchResults := []Circle{}
	query := func(c *mgo.Collection) error {
		fn := c.Find(bson.M{"name": circleName}).All(&searchResults)
		return fn
	}
	search := func() error {
		return Connection.WithCollection("circle", query)
	}
	err := search()
	if err != nil {
		searchErr := "Database Error"
		log.Println(searchErr)
	}

	for i, v := range searchResults {
		circleMembers[i] = v.Name
	}
	return circleMembers
}
コード例 #2
0
ファイル: circle.go プロジェクト: jmadan/go-msgstory
func GetUserCircles(userID string) []string {
	var userCircles []string
	searchResults := []Circle{}
	query := func(c *mgo.Collection) error {
		fn := c.Find(bson.M{"members": userID}).All(&searchResults)
		return fn
	}
	search := func() error {
		return Connection.WithCollection("circle", query)
	}
	err := search()
	if err != nil {
		searchErr := "Database Error"
		log.Println(searchErr)
	}

	for i, v := range searchResults {
		userCircles[i] = v.Name
	}
	return userCircles
}