當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DbConnection.QueryInTx方法代碼示例

本文整理匯總了Golang中github.com/blendlabs/spiffy.DbConnection.QueryInTx方法的典型用法代碼示例。如果您正苦於以下問題:Golang DbConnection.QueryInTx方法的具體用法?Golang DbConnection.QueryInTx怎麽用?Golang DbConnection.QueryInTx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/blendlabs/spiffy.DbConnection的用法示例。


在下文中一共展示了DbConnection.QueryInTx方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: roleExists

// roleExists returns if a role exists or not.
func roleExists(c *spiffy.DbConnection, tx *sql.Tx, roleName string) (bool, error) {
	return c.QueryInTx(`SELECT 1 FROM pg_roles WHERE rolname ilike $1`, tx, roleName).Any()
}
開發者ID:blendlabs,項目名稱:spiffy,代碼行數:4,代碼來源:actions.go

示例2: indexExists

// IndexExists returns if a index exists on a table on the given connection.
func indexExists(c *spiffy.DbConnection, tx *sql.Tx, tableName, indexName string) (bool, error) {
	return c.QueryInTx(`SELECT 1 FROM pg_catalog.pg_index ix join pg_catalog.pg_class t on t.oid = ix.indrelid join pg_catalog.pg_class i on i.oid = ix.indexrelid WHERE t.relname = $1 and i.relname = $2 and t.relkind = 'r'`, tx, strings.ToLower(tableName), strings.ToLower(indexName)).Any()
}
開發者ID:blendlabs,項目名稱:spiffy,代碼行數:4,代碼來源:actions.go

示例3: columnExists

// ColumnExists returns if a column exists on a table on the given connection.
func columnExists(c *spiffy.DbConnection, tx *sql.Tx, tableName, columnName string) (bool, error) {
	return c.QueryInTx(`SELECT 1 FROM information_schema.columns i WHERE i.table_name = $1 and i.column_name = $2`, tx, strings.ToLower(tableName), strings.ToLower(columnName)).Any()
}
開發者ID:blendlabs,項目名稱:spiffy,代碼行數:4,代碼來源:actions.go

示例4: constraintExists

// ConstraintExists returns if a constraint exists on a table on the given connection.
func constraintExists(c *spiffy.DbConnection, tx *sql.Tx, constraintName string) (bool, error) {
	return c.QueryInTx(`SELECT 1 FROM pg_constraint WHERE conname = $1`, tx, strings.ToLower(constraintName)).Any()
}
開發者ID:blendlabs,項目名稱:spiffy,代碼行數:4,代碼來源:actions.go

示例5: tableExists

// TableExists returns if a table exists on the given connection.
func tableExists(c *spiffy.DbConnection, tx *sql.Tx, tableName string) (bool, error) {
	return c.QueryInTx(`SELECT 1 FROM pg_catalog.pg_tables WHERE tablename = $1`, tx, strings.ToLower(tableName)).Any()
}
開發者ID:blendlabs,項目名稱:spiffy,代碼行數:4,代碼來源:actions.go


注:本文中的github.com/blendlabs/spiffy.DbConnection.QueryInTx方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。