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.

20 lines
444 B

require_relative "../models"
module Alphadex
def self.add_bookmark(url, title, note, tags)
fail "url already exists" unless Url.where(url:).empty?
DB.transaction do
entity = Entity.create
entity.url = Url.new(url:)
entity.title = Title.new(title:)
entity.add_note(text: note)
tags.map { Tag.find_or_create(name: _1) }.each do |tag|
entity.add_tag(tag)
end
entity
end
end
end