本文整理汇总了Golang中github.com/quintans/goSQL/db.Table.GetDeletionColumn方法的典型用法代码示例。如果您正苦于以下问题:Golang Table.GetDeletionColumn方法的具体用法?Golang Table.GetDeletionColumn怎么用?Golang Table.GetDeletionColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/quintans/goSQL/db.Table
的用法示例。
在下文中一共展示了Table.GetDeletionColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SoftDeleteByIdAndVersion
func SoftDeleteByIdAndVersion(DB db.IDb, table *db.Table, id int64, version int64) error {
deletion := table.GetDeletionColumn()
if deletion == nil {
return dbx.NewPersistenceFail("DAOUtils.SoftDeleteByIdAndVersion", "Table "+table.GetName()+" does not have a deletion type column to do a soft delete.")
}
keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)
versionColumn := table.GetVersionColumn()
result, err := DB.Update(table).
Set(deletion, tk.Milliseconds()).
Set(versionColumn, version+1).
Where(
keyColumn.Matches(id),
versionColumn.Matches(version),
).
Execute()
if err != nil {
return err
}
if result == 0 {
return dbx.NewOptimisticLockFail("DAOUtils.removeByIdVersion: Unable to soft delete by id and version for the table " + table.GetName())
}
return nil
}
示例2: FindAll
func FindAll(DB db.IDb, table *db.Table, instance interface{}) (coll.Collection, error) {
logger.CallerAt(1).Debugf("DAOUtils.FetchAll")
deletion := table.GetDeletionColumn()
q := DB.Query(table).All()
if deletion != nil {
q.Where(deletion.Matches(NOT_DELETED))
}
return q.ListOf(instance)
}