Reputation: 721
Is there a native Sequel way to implement Datamapper's first_or_create
method?
Or am I bound to combine selects and inserts?
Upvotes: 1
Views: 1252
Reputation: 24617
I think find_or_create should work for you.
Like find but invokes create with given conditions when record does not exist. Unlike find in that the block used in this method is not passed to find, but instead is passed to create only if find does not return an object.
Upvotes: 4