Introducing new Flow querying

Jamie Holdroyd profile picture Written by: Jamie Holdroyd - Published on: 03 Apr 2015
Today we’re introducing a new way to query Flows, allowing you to do much more advanced queries, including cross-flow querying and array checks.

For a long time, we've been asked by a large number of our community if there was a way to do more advanced queries on our Flows. We spent a lot of time looking at what would be needed and how to implement an elegant solution that was backward compatible. There was a good chance that any system we implemented wouldn’t work with our SDKs or could break existing projects. The solution we came up with was to use our existing URL structure but to add more flexibility to it. There are now a number of operators that can be used as part of the column, for example:

# Equals
products?title=Real+Product

# Does not equal
products?title!=Example+Product

# Greater than
products?price>=49.99

# Less than
products?price<=99.99

And of course, you can chain all of these methods into one query.

products?price>=49.99&price<=99.99&title!=Example+Product

You can now also do "like” and "not like" queries to make searching on titles, slugs and descriptions much easier.

# Like
products?title*=Chair

# Not Like
products?title!*=Sofa

As well as this we introduced the "in" clause to allow you to check if your column is in an array of items:

products?category=in('618', '614')

Using IDs isn’t always the nicest way to go about doing things so we wanted to make it easier. To do this we enabled cross-flow querying, meaning columns within a relationship can now be queried. You can now tie together search queries for attributes, custom options and more, all by using the dot separator.

products?category.slug=featured

Again everything can be chained into one complex query:

products?title*=Chair&category.slug!=in('sofa', 'chair')&price>=49.99&price<=99.99

While these examples are all using products, they will work on any flow - including custom created flows.

These arguments are now available in version one of the API and we're really excited to see what you guys do with these!

Build something amazing with Moltin