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 ornil
is normal according to your business.
| method | value exist | doesn't exist |
| get | value | raise a error |
| first | value | nil |
Written by Qi Liu
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sequel
Authors
Related Tags
#sequel
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#