2017-07-26 13:57:10 +02:00
|
|
|
package qb
|
|
|
|
|
|
|
|
|
|
import (
|
2017-07-27 09:48:33 +02:00
|
|
|
"bytes"
|
2017-08-01 12:44:10 +02:00
|
|
|
"time"
|
2017-07-26 13:57:10 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// placeholders returns a string with count ? placeholders joined with commas.
|
2017-07-27 09:48:33 +02:00
|
|
|
func placeholders(cql *bytes.Buffer, count int) {
|
2017-07-26 13:57:10 +02:00
|
|
|
if count < 1 {
|
2017-07-27 09:48:33 +02:00
|
|
|
return
|
2017-07-26 13:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-27 09:48:33 +02:00
|
|
|
for i := 0; i < count-1; i++ {
|
|
|
|
|
cql.WriteByte('?')
|
|
|
|
|
cql.WriteByte(',')
|
|
|
|
|
}
|
|
|
|
|
cql.WriteByte('?')
|
2017-07-26 13:57:10 +02:00
|
|
|
}
|
2017-08-01 12:44:10 +02:00
|
|
|
|
|
|
|
|
// TTL converts duration to format expected in USING TTL clause.
|
|
|
|
|
func TTL(d time.Duration) int64 {
|
|
|
|
|
return int64(d.Seconds())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Timestamp converts time to format expected in USING TIMESTAMP clause.
|
|
|
|
|
func Timestamp(t time.Time) int64 {
|
|
|
|
|
return t.UnixNano() / 1000
|
|
|
|
|
}
|