You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
792 B
42 lines
792 B
require "date"
|
|
|
|
require_relative "db"
|
|
|
|
Sequel::Model.plugin :timestamps
|
|
|
|
module Alphadex
|
|
class Entity < Sequel::Model
|
|
one_to_many :notes
|
|
one_to_many :sources
|
|
one_to_one :title
|
|
many_to_many :tags
|
|
one_to_one :url
|
|
|
|
# override this since I have `created_at` on this join table for some reason
|
|
def add_tag(tag)
|
|
DB[:entities_tags].insert(entity_id: self.id, tag_id: tag.id, created_at: DateTime.now)
|
|
end
|
|
end
|
|
|
|
class Note < Sequel::Model
|
|
many_to_one :entity
|
|
end
|
|
|
|
class Source < Sequel::Model
|
|
many_to_one :entity
|
|
many_to_one :source, class: :Entity
|
|
end
|
|
|
|
class Title < Sequel::Model
|
|
many_to_one :entity
|
|
end
|
|
|
|
class Tag < Sequel::Model
|
|
many_to_many :entities
|
|
end
|
|
|
|
class Url < Sequel::Model
|
|
many_to_one :entity
|
|
end
|
|
end
|