Beispiel #1
0
func GetHost(db *database.Database, id string) (host *Host, err error) {
	coll := db.Hosts()
	host = &Host{}

	err = coll.FindId(id).One(host)
	if err != nil {
		err = database.ParseError(err)
		return
	}

	return
}
Beispiel #2
0
func GetHosts(db *database.Database) (hosts []*Host, err error) {
	coll := db.Hosts()
	hosts = []*Host{}

	cursor := coll.Find(nil).Iter()

	err = cursor.All(&hosts)
	if err != nil {
		err = database.ParseError(err)
		return
	}

	return
}