onyxframework / sql

A delightful SQL ORM ☺️
https://api.onyxframework.com/sql
MIT License
91 stars 7 forks source link

feat: query callbacks in model #102

Open qszhu opened 5 years ago

qszhu commented 5 years ago

Not sure whether this is the best way to do it. I added these so that I could write something like the following in a base model:

module Models::Base

  # ...

  def before_insert
    @created_at = @updated_at = Time.utc
  end

  def before_update
    @updated_at = Time.utc
  end
end