Esempio n. 1
0
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
}
Esempio n. 2
0
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
}