本文整理匯總了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
}