本文整理汇总了Golang中table.Table.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang Table.Delete方法的具体用法?Golang Table.Delete怎么用?Golang Table.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类table.Table
的用法示例。
在下文中一共展示了Table.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findAndDelete
// Deletes rows in a table of RA result according to some select conditions.
// The RA result is made a copy before using select conditions.
func findAndDelete(t *table.Table, query *ra.Result, conditions ...ra.Condition) int {
_, status := query.Copy().MultipleSelect(conditions...)
if status != st.OK {
return status
}
for _, i := range query.Tables[t.Name].RowNumbers {
status = t.Delete(i)
if status != st.OK {
return status
}
}
return t.Flush()
}
示例2: Delete
func (tr *Transaction) Delete(t *table.Table, rowNumber int) int {
// Execute "before delete" triggers.
beforeTable, status := tr.DB.Get("~before")
if status != st.OK {
return status
}
row, status := t.Read(rowNumber)
if status != st.OK {
return status
}
triggerRA := ra.New()
_, status = triggerRA.Load(beforeTable)
if status != st.OK {
return status
}
_, status = triggerRA.Select("TABLE", filter.Eq{}, t.Name)
if status != st.OK {
return status
}
status = trigger.ExecuteTrigger(tr.DB, t, triggerRA, "DE", row, nil)
if status != st.OK {
return status
}
// Update the row.
status = t.Delete(rowNumber)
if status != st.OK {
return status
}
// Execute "after delete" triggers.
afterTable, status := tr.DB.Get("~after")
if status != st.OK {
return status
}
triggerRA = ra.New()
_, status = triggerRA.Load(afterTable)
if status != st.OK {
return status
}
_, status = triggerRA.Select("TABLE", filter.Eq{}, t.Name)
if status != st.OK {
return status
}
status = trigger.ExecuteTrigger(tr.DB, t, triggerRA, "DE", row, nil)
if status != st.OK {
return status
}
// Log the deleted row.
tr.Log(&UndoDelete{t, rowNumber})
return st.OK
}