ruby-on-railsactiverecordshopifyshopify-appactiveresource

Filtering Active Resource Objects Using Where Clause


I am looking to build a basic Shopify app using Ruby on Rails.

I am using the Shopify_app gem to faciliate my API calls to Shopify.

For example

orders = ShopifyAPI::Order.find(:all, :params => {:limit => 3})

I am really struggling with how to filter this data.

Specifically I would like to include a date picker on the front end of the application which would filter orders based on the created_at date.

However, when querying an Active Resource I do not believe you can use the 'where' method and other methods such as 'select' and 'find' are not suitable.

My question then, is this.

Is there a way of querying and filtering the data without actually loading the data into the database and querying with Active Record methods?

I would like to filter and extract data but not store it as I have no need for this.

Any help or pointers would be greatly appreciated.


Solution

  • If you examine the documentation, you will see that endpoints often come with useful filters. So you gather filter inputs from your front-end, and use them in your ActiveResource queries, or GraphQL queries. So while you do not get the same level of filtering as your own DB might offer, you can still filter. As your question already states, you might want to filter on date, and that is supported.