package main

import "encoding/json"

type Account struct {
	Username  string `json:"username"`
	Password  string `json:"password"`
	Email     string `json:"email"`
	Cookies   []byte `json:"cookies"`
	Available bool   `json:"available"`
}

func GetAvailableAccounts() ([]Account, error) {

	data, count, err := client.From("accounts").Select("*", "exact", false).Eq("available", "true").Execute()

	if err != nil {
		return nil, err
	}

	//return count == 1, nil

	_ = count

	res := make([]Account, 0, count)
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}

	return res, nil

}

func UpdateCookies(username string, cookies []byte) error {

	return nil
}
