Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2016 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/cf2f6db17a0eeae7a5fc to your computer and use it in GitHub Desktop.
Save anonymous/cf2f6db17a0eeae7a5fc to your computer and use it in GitHub Desktop.
class Sequel::Dataset
def has(h)
self.where(h).count > 0
end
def ins_uniq(data, fld)
insert(data) unless has( fld.to_sym => data[fld] )
end
end
DB[:bookmarks].ins_uniq( { url: c['href'], title: c.xpath('./title').text, origin: origin }, :url)
# if url is not already there
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment