ref: 1314a9d1bfc7280861f82a2e610433ed604084ba
server/db/clients.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
/** * Yats - yats * * This file is licensed under the Affero General Public License version 3 or * later. See the COPYING file. * * @author Paolo Lulli <kevwe.com> * @copyright Paolo Lulli 2024 */ package db import ( "fmt" "time" "yats-server/model" "github.com/gocql/gocql" ) func GetClientsList(session *gocql.Session) []model.ClientInfo { var clients []model.ClientInfo m := map[string]interface{}{} q := fmt.Sprintf("SELECT id, created, name FROM client") fmt.Println(q) iter := session.Query(q).Iter() for iter.MapScan(m) { clients = append(clients, model.ClientInfo{ ID: m["id"].(string), Created: m["created"].(time.Time).UnixMilli(), Name: m["name"].(string), }) m = map[string]interface{}{} } return clients } |