- 
                Notifications
    You must be signed in to change notification settings 
- Fork 40
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Currently returns nil if used on a AR class, and throws a non-related error if used on a scope.
THIS WAS THE ORIGINAL CONCLUSION BUT ITS INCORRECT SEE DISCUSSION:
The reasons we won't implement where is that it could be used to insecurely determine counts on data.
For exampleCustomers.where(top_secret_attribute: true).countcould be executed from the JS console to find the count of customers with the top_secret_attribute.
where should be implemented as a scope.
We will need to add scope called __hyperstack_internal_where_scope
class ActiveRecord::Base 
  scope __hyperstack_internal_where_scope, 
    ->(attrs) { where(attrs) }, # server side we just call where
    filter: ->(attrs) { !attrs.detect { |k, v| self[k] != v } # client side optimization
  def self.where(attrs) 
    __hyperstack_internal_where_scope(attrs)
  end if RUBY_ENGINE == 'opal'
endOn the client side we can add the class level where method to ActiveRecord::Base and which simpy calls the `__hyperstack_internal_where_scope.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers