Exemplo n.º 1
0
Arquivo: basic.go Projeto: qtabot/cqlc
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).
		SetTimeUUID(BASIC.TIMEUUID_COLUMN, basic.TimeuuidColumn).
		SetBoolean(BASIC.BOOLEAN_COLUMN, basic.BooleanColumn).
		SetString(BASIC.TEXT_COLUMN, basic.TextColumn).
		SetString(BASIC.VARCHAR_COLUMN, basic.VarcharColumn).
		SetMap(BASIC.MAP_COLUMN, basic.MapColumn).
		SetArray(BASIC.ARRAY_COLUMN, basic.ArrayColumn).
		SetDecimal(BASIC.DECIMAL_COLUMN, basic.DecimalColumn).
		Exec(s)

	if err != nil {
		log.Fatalf("Could not execute query: %v", err)
		os.Exit(1)
	}
}
Exemplo n.º 2
0
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)
}