当前位置: 首页>>代码示例>>Golang>>正文


Golang db.Table类代码示例

本文整理汇总了Golang中github.com/quintans/goSQL/db.Table的典型用法代码示例。如果您正苦于以下问题:Golang Table类的具体用法?Golang Table怎么用?Golang Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Table类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: FindById

// the result of the query is put in the passed struct.
// returns true if a result was found, false if no result
func FindById(DB db.IDb, table *db.Table, instance interface{}, id int64) (bool, error) {
	logger.CallerAt(1).Debugf("DAOUtils.FindById: %v", id)

	keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)

	return DB.Query(table).
		All().
		Where(keyColumn.Matches(id)).
		SelectTo(instance)
}
开发者ID:quintans,项目名称:toolkit,代码行数:12,代码来源:DAOUtils.go

示例2: DeleteById

func DeleteById(DB db.IDb, table *db.Table, id int64) (bool, error) {
	logger.CallerAt(1).Debugf("DAOUtils.deleteById: %v", id)

	keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)

	result, err := DB.Delete(table).
		Where(keyColumn.Matches(id)).
		Execute()

	return result != 0, err
}
开发者ID:quintans,项目名称:toolkit,代码行数:11,代码来源:DAOUtils.go

示例3: 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)
}
开发者ID:quintans,项目名称:toolkit,代码行数:12,代码来源:DAOUtils.go

示例4: 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
}
开发者ID:quintans,项目名称:toolkit,代码行数:28,代码来源:DAOUtils.go

示例5: DeleteByIdAndVersion

func DeleteByIdAndVersion(DB db.IDb, table *db.Table, id int64, version int64) error {
	logger.CallerAt(1).Debugf("DAOUtils.removeByIdVersion: id: %v, version: %v", id, version)

	keyColumn := table.GetKeyColumns().Enumerator().Next().(*db.Column)
	versionColumn := table.GetVersionColumn()

	result, err := DB.Delete(table).
		Where(
			keyColumn.Matches(id),
			versionColumn.Matches(version),
		).
		Execute()

	if err != nil {
		return err
	}

	if result == 0 {
		return dbx.NewOptimisticLockFail("DAOUtils.removeByIdVersion: Unable to delete by id and version for the table " + table.GetName())
	}

	return nil
}
开发者ID:quintans,项目名称:toolkit,代码行数:23,代码来源:DAOUtils.go

示例6: TableName

// FROM
func (this *GenericTranslator) TableName(table *db.Table) string {
	return table.GetName()
}
开发者ID:quintans,项目名称:goSQL,代码行数:4,代码来源:GenericTranslator.go

示例7: TableName

func (this *FirebirdSQLTranslator) TableName(table *db.Table) string {
	return "\"" + strings.ToUpper(table.GetName()) + "\""
}
开发者ID:quintans,项目名称:goSQL,代码行数:3,代码来源:FirebirdSQLTranslator.go

示例8: TableName

func (this *MySQL5Translator) TableName(table *db.Table) string {
	return "`" + strings.ToUpper(table.GetName()) + "`"
}
开发者ID:quintans,项目名称:goSQL,代码行数:3,代码来源:MySQL5Translator.go

示例9: TableName

func (this *OracleTranslator) TableName(table *db.Table) string {
	return "\"" + strings.ToUpper(table.GetName()) + "\""
}
开发者ID:quintans,项目名称:goSQL,代码行数:3,代码来源:OracleTranslator.go

示例10: TableName

func (this *PostgreSQLTranslator) TableName(table *db.Table) string {
	return strings.ToLower(table.GetName())
}
开发者ID:quintans,项目名称:goSQL,代码行数:3,代码来源:PostgreSQLTranslator.go


注:本文中的github.com/quintans/goSQL/db.Table类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。