ActiveRecord has a default_scope
class method for specifying the default scope. for instance
class User < ActiveRecord::Base default_scope where(:deleted => false) end User.all
How to do it in Sequel::Model
?
EDIT:
After some googling, I found some useful information.
class User < Sequel::Model
The generated query is as follows:
User.all # => SELECT * FROM `users` WHERE (`deleted` IS FALSE)
By the way : the equivalent of unscoped
is unfiltered
:
User.unfiltered.all # => SELECT * FROM `users`
But , there is one problem. If you try to update a user that you received from an unfiltered dataset, he tries to update the user using this dataset.
User.create(disabled: true, deleted: true) User.all
So, I returned to the beginning. Any workaround for this?
iblue source share