// RowsToAppGroup get applications groups from sql rows
RowsToAppGroup get applications groups from sql rows
// RowsToAppGroup get applications groups from sql rows
func RowsToAppGroup(rows *sql.Rows, containsPagination bool) []ApplicationGroup {
	var appGroups []ApplicationGroup
	for rows.Next() {
		var appG ApplicationGroup
		var id string
		var servicesList string
		var a int
		if containsPagination {
			rows.Scan(&id, &appG.Name, &servicesList, &a)
		} else {
			rows.Scan(&id, &appG.Name, &servicesList)
		}
		servicesListArray := strings.Split(servicesList, ",")
		if bson.IsObjectIdHex(id) {
			appG.Id = bson.ObjectIdHex(id)
		} else {
			appG.Id = bson.NewObjectId()
		}
		services := make([]bson.ObjectId, 0)
		for _, s := range servicesListArray {
			if !bson.IsObjectIdHex(strings.Trim(s, " ")) {
				continue
			}
			services = append(services, bson.ObjectIdHex(strings.Trim(s, " ")))
		}
		appG.Services = services
		appGroups = append(appGroups, appG)
	}
	defer rows.Close()
	return appGroups
}
func RowsToAppGroup ( rows * sql . Rows , containsPagination bool ) [ ] ApplicationGroup { var appGroups [ ] ApplicationGroup for rows . Next ( ) { var appG ApplicationGroup var id string var servicesList string var a int if containsPagination { rows . Scan ( & id , & appG . Name , & servicesList , & a ) } else { rows . Scan ( & id , & appG . Name , & servicesList ) } servicesListArray := strings . Split ( servicesList , " " ) if bson . IsObjectIdHex ( id ) { appG . Id = bson . ObjectIdHex ( id ) } else { appG . Id = bson . NewObjectId ( ) } services := make ( [ ] bson . ObjectId , 0 ) for _ , s := range servicesListArray { if ! bson . IsObjectIdHex ( strings . Trim ( s , " " ) ) { continue } services = append ( services , bson . ObjectIdHex ( strings . Trim ( s , " " ) ) ) } appG . Services = services appGroups = append ( appGroups , appG ) } defer rows . Close ( ) return appGroups }
RowsToAppGroup get applications groups from sql rows
RowsToAppGroup get applications groups from sql rows