This PR contains some refactoring and a new record column that allows you to use a BinaryMarshaler and BinaryUnmarshaler type to be stored. As such, it supports types that implement this standard way of encoding, for example time.Time.
col := NewCollection()
col.CreateColumn("timestamp", ForRecord(func() *time.Time {
return new(time.Time)
}, nil))
// Insert the time, it implements binary marshaler
idx, _ := col.Insert(func(r Row) error {
now := time.Unix(1667745766, 0)
r.SetRecord("timestamp", &now)
return nil
})
// We should be able to read back the time
col.QueryAt(idx, func(r Row) error {
ts, ok := r.Record("timestamp")
assert.True(t, ok)
assert.Equal(t, "November", ts.(*time.Time).UTC().Month().String())
return nil
})
This PR contains some refactoring and a new
record
column that allows you to use aBinaryMarshaler
andBinaryUnmarshaler
type to be stored. As such, it supports types that implement this standard way of encoding, for exampletime.Time
.