Пример #1
0
func (this *Tweet) Insert() error {
	session, err := dao.GetSession()
	if err != nil {
		return err
	}

	b := cqlr.Bind(`INSERT INTO tweet (timeline, id, text) VALUES (?, ?, ?)`, this)
	return b.Exec(session)
}
Пример #2
0
//create table example.user(id UUID, login text, passwd text, PRIMARY KEY(id));
//create index on example.user(login);
//insert into example.user(id, login, passwd) values (now(), 'admin', 'f807c2b4caa8ca621298907e5372c975a6e07322');
func main() {
	log15.Root().SetHandler(log15.CallerStackHandler("%+v", log15.StdoutHandler))
	session, err := dao.GetSession()
	if err != nil {
		log15.Error(err.Error())
		os.Exit(1)
	}
	defer session.Close()
	www.StartWebServer()
	os.Exit(0)
}
Пример #3
0
func GetAllTweetsForTimeLine(timeLine string) ([]Tweet, error) {
	session, err := dao.GetSession()
	if err != nil {
		return nil, err
	}

	q := session.Query(`SELECT text, id, timeline FROM tweet WHERE timeline = ?`, timeLine)
	bind := cqlr.BindQuery(q)
	defer bind.Close()

	var tweets []Tweet
	t := Tweet{}
	for bind.Scan(&t) {
		tweets = append(tweets, t)
	}
	return tweets, nil
}