本文整理汇总了Golang中github.com/relops/cqlc/cqlc.Context类的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Context类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: create
func create(ctx *cqlc.Context, s *gocql.Session, basic Basic) {
err := ctx.Upsert(BASIC).
SetString(BASIC.ID, basic.Id).
SetInt32(BASIC.INT32_COLUMN, basic.Int32Column).
SetInt64(BASIC.INT64_COLUMN, basic.Int64Column).
SetFloat32(BASIC.FLOAT_COLUMN, basic.FloatColumn).
SetFloat64(BASIC.DOUBLE_COLUMN, basic.DoubleColumn).
SetString(BASIC.ASCII_COLUMN, basic.AsciiColumn).
SetTimestamp(BASIC.TIMESTAMP_COLUMN, basic.TimestampColumn).
SetUUID(BASIC.UUID_COLUMN, basic.UuidColumn).
SetTimeUUID(BASIC.TIMEUUID_COLUMN, basic.TimeuuidColumn).
SetBoolean(BASIC.BOOLEAN_COLUMN, basic.BooleanColumn).
SetString(BASIC.TEXT_COLUMN, basic.TextColumn).
SetString(BASIC.VARCHAR_COLUMN, basic.VarcharColumn).
SetStringStringMap(BASIC.MAP_COLUMN, basic.MapColumn).
SetStringSlice(BASIC.ARRAY_COLUMN, basic.ArrayColumn).
SetStringSlice(BASIC.SET_COLUMN, basic.SetColumn).
SetDecimal(BASIC.DECIMAL_COLUMN, basic.DecimalColumn).
SetVarint(BASIC.VARINT_COLUMN, basic.VarintColumn).
Exec(s)
if err != nil {
log.Fatalf("Could not execute query: %v", err)
os.Exit(1)
}
}
开发者ID:arkxu,项目名称:cqlc,代码行数:27,代码来源:basic.go
示例2: expectComparisonResult
func expectComparisonResult(ctx *cqlc.Context,
s *gocql.Session,
callback func([]ClusterByStringAndInt) bool,
comparisons ...cqlc.Condition) bool {
iter, err := ctx.Select().
From(CLUSTER_BY_STRING_AND_INT).
Where(comparisons...).
Fetch(s)
if err != nil {
log.Fatalf("Could not run query: %v", err)
os.Exit(1)
}
clustered, err := BindClusterByStringAndInt(iter)
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
err = iter.Close()
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
return callback(clustered)
}
开发者ID:arkxu,项目名称:cqlc,代码行数:29,代码来源:comparison.go
示例3: get
func get(s *gocql.Session, ctx *cqlc.Context, key string) (bool, string) {
var value string
found, err := ctx.Select(SHARED.VALUE).
From(SHARED).
Where(SHARED.ID.Eq("foo")).
Bind(SHARED.VALUE.To(&value)).
FetchOne(s)
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
return found, value
}
开发者ID:arkxu,项目名称:cqlc,代码行数:15,代码来源:keyspace.go
示例4: deleteByTimestamp
func deleteByTimestamp(ctx *cqlc.Context, s *gocql.Session, w WhenRowKey, t gocql.UUID) error {
return ctx.
Delete().
From(w).
Where(w.WhenColumn().Eq(t)).
Exec(s)
}
开发者ID:arkxu,项目名称:cqlc,代码行数:7,代码来源:composition.go
示例5: fetchOne
func fetchOne(ctx *cqlc.Context, s *gocql.Session, w WhenRowKey, t gocql.UUID, binding cqlc.ColumnBinding) (bool, error) {
return ctx.
Select().
From(w).
Where(w.WhenColumn().Eq(t)).
Bind(binding).
FetchOne(s)
}
开发者ID:arkxu,项目名称:cqlc,代码行数:8,代码来源:composition.go
示例6: fetchFirstBasic
func fetchFirstBasic(ctx *cqlc.Context, s *gocql.Session, key string) *Basic {
iter, err := ctx.Select().From(REALLY_BASIC).Where(REALLY_BASIC.ID.Eq("x")).Fetch(s)
basics, err := BindBasic(iter)
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
err = iter.Close()
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
if len(basics) > 0 {
return &basics[0]
} else {
return nil
}
}
开发者ID:arkxu,项目名称:cqlc,代码行数:22,代码来源:delete.go
示例7: fetchFirstReallyBasic
func fetchFirstReallyBasic(ctx *cqlc.Context, s *gocql.Session, key string) ReallyBasic {
iter, err := ctx.Select().From(REALLY_BASIC).Where(REALLY_BASIC.ID.Eq(key)).Fetch(s)
basics, err := BindReallyBasic(iter)
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
err = iter.Close()
if err != nil {
log.Fatalf("Could not bind data: %v", err)
os.Exit(1)
}
if len(basics) != 1 {
log.Fatalf("Could not fetch data for key: %s", key)
os.Exit(1)
}
return basics[0]
}
开发者ID:EverythingMe,项目名称:cqlc,代码行数:23,代码来源:bind.go
示例8: runWithContext
func runWithContext(s *gocql.Session, ctx *cqlc.Context) string {
result := "FAILED"
shared := Shared{
Id: "foo",
Value: "bar",
}
err := ctx.Store(SHARED.Bind(shared)).Exec(s)
if err != nil {
log.Fatalf("Could not store data: %v", err)
os.Exit(1)
}
found, value := get(s, ctx, "foo")
if found && value == "bar" {
err := ctx.Upsert(SHARED).SetString(SHARED.VALUE, "baz").Where(SHARED.ID.Eq("foo")).Exec(s)
if err != nil {
log.Fatalf("Could not upsert row: %v", err)
os.Exit(1)
}
found, value := get(s, ctx, "foo")
if found && value == "baz" {
err = ctx.Delete().From(SHARED).Where(SHARED.ID.Eq("foo")).Exec(s)
if err != nil {
log.Fatalf("Could not delete row: %v", err)
os.Exit(1)
}
found, _ := get(s, ctx, "foo")
if !found {
result = "PASSED"
}
}
}
return result
}
开发者ID:arkxu,项目名称:cqlc,代码行数:47,代码来源:keyspace.go
示例9: upsert
func upsert(ctx *cqlc.Context, s *gocql.Session, w WhenRowKey, t gocql.UUID, binding cqlc.ColumnBinding) error {
return ctx.Upsert(w).
Apply(binding).
Where(w.WhenColumn().Eq(t)).
Exec(s)
}
开发者ID:arkxu,项目名称:cqlc,代码行数:6,代码来源:composition.go
注:本文中的github.com/relops/cqlc/cqlc.Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论