Skip to content

Commit

Permalink
Store duration as integer
Browse files Browse the repository at this point in the history
  • Loading branch information
asdine committed Sep 28, 2020
1 parent dfdbc16 commit 988a11e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions document/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (s structDocument) MarshalJSON() ([]byte, error) {
func NewValue(x interface{}) (Value, error) {
// Attempt exact matches first:
switch v := x.(type) {
case time.Duration:
return NewIntegerValue(v.Nanoseconds()), nil
case time.Time:
return NewTextValue(v.Format(time.RFC3339Nano)), nil
case nil:
Expand Down

0 comments on commit 988a11e

Please sign in to comment.