Beispiel #1
0
func scanItems(rows sqliface.Rows) ([]*SavedItem, error) {
	var err error
	// intializing so we return an empty array in case of 0
	items := []*SavedItem{}
	for rows.Next() {
		item := &SavedItem{}
		err = rows.Scan(&item.UserID, &item.URL, &item.Timestamp)
		if err != nil {
			return nil, err
		}
		items = append(items, item)
	}
	return items, nil
}
Beispiel #2
0
func scanDatas(rows sqliface.Rows) (datas []Data, err error) {
	var data Data
	for rows.Next() {
		err = scanData(rows, &data)
		if err != nil {
			rows.Close()
			return datas, err
		}

		datas = append(datas, data)
	}
	return datas, rows.Err()
}