Use Timestamps
Add Timestamps to Schema
schema.table :posts do
primary :id, Int64, auto_increment: true
column :title, String
timestamps # Adds created_at and updated_at columns
end
schema.posts.create!Add to Model
struct Post
include CQL::ActiveRecord::Model(Int64)
db_context MyDB, :posts
property id : Int64?
property title : String
property created_at : Time?
property updated_at : Time?
def initialize(@title : String)
end
endAutomatic Timestamps
Manual Timestamps with Callbacks
Query by Timestamp
Add Timestamps to Existing Table
Useful Timestamp Methods
Verify It Works
Related
Last updated
Was this helpful?