示例#1
0
// Delete a fragment
func (self *fragments) Delete(fragment *model.Fragment) error {
	if fragment == nil {
		return n.LogFail(1, "Invalid request to delete nil record (bad id?)")
	}

	var err = self.db.Delete("worker.Fragment", fragment.Id)
	if err != nil {
		return n.LogFail(1, "Failed to delete record: %s", err.Error())
	}

	// If we got here, remove that id from all indexes
	self.index.Delete(fragment.Id)

	return nil
}
示例#2
0
// Update, expand tags
func (self *fragments) Update(f *viewmodel.FragmentViewModel) error {
	var fragment, _, err = self.Get(f.Id)
	if err != nil {
		return n.LogFail(1, "Unable to update fragment; no match for id '%d'", f.Id)
	}

	fragment.Load(f)
	err = self.update(fragment)
	return err
}