Ejemplo n.º 1
0
func (store FolderStore) AddEntry(name data.ProjectName, entry data.Entry) error {
	db := store.db()
	err := db.Put(entry.Values(), name.Values()...)
	if err != nil {
		return errgo.Notef(err, "can not put entry into the database")
	}

	return nil
}
Ejemplo n.º 2
0
func (store FolderStore) GetProject(name data.ProjectName) (data.Project, error) {
	db := store.db()
	values, err := db.Get(name.Values()...)
	if err != nil {
		return data.Project{}, errgo.Notef(err, "can not put entry into the database")
	}

	var entries []data.Entry
	for _, value := range values {
		entry, err := data.ParseEntry(value)
		if err != nil {
			return data.Project{}, errgo.Notef(err, "can not parse entry from value")
		}

		entries = append(entries, entry)
	}

	return data.Project{Name: name, Entries: entries}, nil
}