Ok, i had read a lot of stuff on the weekend but i´m only one step forward....
So, i can add one dataset into table but not more... For example, this works:
type RoomsItem struct {
Room string `cql:"room"`
Available int `cql:"available"`
}
func main() {
srv, err := newCqlSession()
if err != nil {
log.Fatal(err)
}
rooms := &RoomsItem{
Room: "main",
Available: 1,
}
err = srv.Query("INSERT INTO objects(id, rooms) VALUES(?, ?)", gocql.TimeUUID(), rooms).Exec()
if err != nil {
log.Fatal(err)
}
}
With this example i had insert "{"room":"main", "Available": 1}" to the table, fine... so but i will add more than one;-) ( {"room":"main", "Available": 1},{"room":"bla", "Available": 5}....)
for this, i had change to this:
type RoomsItem struct {
Room string `cql:"room"`
Available int `cql:"available"`
}
type Rooms struct {
Items []RoomsItem
}
func main() {
srv, err := newCqlSession()
if err != nil {
log.Fatal(err)
}
items := []RoomsItem{}
rooms := Rooms{items}
rooms.AddItem(RoomsItem{Room:"ground", Available:1})
err = srv.Query("INSERT INTO objects(id, rooms) VALUES(?, ?)", gocql.TimeUUID(), rooms).Exec()
if err != nil {
log.Fatal(err)
}
}
func (room *Rooms) AddItem(item RoomsItem) []RoomsItem {
room.Items = append(room.Items, item)
return room.Items
}
And now. i become the failure "cannot marshal main.Rooms into immodb.objects{room=varchar,available=int}"???
I´m really confussed;-))