Ejemplo n.º 1
0
// Get Returns template with gien name
func (u Utemplates) Get(templateName string) *UserTemplate {
	templ := &UserTemplate{}
	err := boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Get(templateName, templ)
	if err != nil {
		log.Println("Can't load user template:", err)
		return nil
	}
	return templ
}
Ejemplo n.º 2
0
// GetAll Get all tamplates with their names
func (u Utemplates) GetAll() (map[string]UserTemplate, error) {
	templs := map[string]UserTemplate{}

	ut, err := boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).GetAll(&UserTemplate{})
	if err != nil {
		return templs, err
	}

	for k, v := range ut {
		templs[k] = *v.(*UserTemplate)
	}
	return templs, nil
}
Ejemplo n.º 3
0
//Delete Deletes template from db
func (u Utemplates) Delete(templateName string) {
	boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Delete(templateName)
}
Ejemplo n.º 4
0
// Set Creates new or update entry for template
func (u Utemplates) Set(templateName string, templ UserTemplate) {
	boltdb.DB(u.BoltDBMain, u.DataEncoding).Bucket(u.BotlDBUserTemplatesBacket).Set(templateName, templ)
}