qb: TTL and Timestamp named parameters
This commit is contained in:
11
qb/utils.go
11
qb/utils.go
@@ -2,6 +2,7 @@ package qb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"time"
|
||||
)
|
||||
|
||||
// placeholders returns a string with count ? placeholders joined with commas.
|
||||
@@ -16,3 +17,13 @@ func placeholders(cql *bytes.Buffer, count int) {
|
||||
}
|
||||
cql.WriteByte('?')
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user