class

Marten::DB::Field::Duration

Inherits Marten::DB::Field::Base / Reference / Object

A duration model field.

Duration fields are persisted as big integers (number of nanoseconds) in the underlying database. They are converted to Time::Span objects when the corresponding values are read from the database.

Constructors

new(id : ::String, primary_key = false, default : Time::Span | Nil = nil, blank = false, null = false, unique = false, index = false, db_column = nil)
Source

Instance methods

default

Returns the default value of the field if any.

Source
from_db(value) : Time::Span | Nil

Converts the raw DB value to the corresponding field value.

Source
from_db_result_set(result_set : ::DB::ResultSet) : Time::Span | Nil

Extracts the field value from a DB result set and returns the right object corresponding to this value.

Source
to_column

Returns a migration column object corresponding to the field at hand.

Source
to_db(value) : ::DB::Any

Converts the field value to the corresponding DB value.

Source