Last Updated: February 25, 2016
·
355
· lovio

Sequel's get and first

Sequel is a DSL for manipulating database written in Ruby. It's quite same as th famous ORM gem ActiveRecord. Haven't delved into AR, I have to say each would hava each advantages.

Using Sequel you'll come across the scenery you need system to return a value from the db. What about no corresponding value?

  • Maybe you wanna use get , and it will automaticly raise an exception if no value returned.
  • Using first will also meet your requirements, and if no value returned it wil get nil. It's very useful when you don't want to stop your program or nil is normal according to your business.

| method | value exist | doesn't exist |

| get | value | raise a error |

| first | value | nil |