[Best Practice] JSON as SQL vs JS Query vs JS Transformer?

The scenario you suggest definitely calls for JSON SQL. If you can reason with the problem as linking multiple "tables" with a common ID then JSON SQL is the exact tool you need. If you have a basic understanding of SQL then it is far easier to build and understand than a bunch of JS array functions which I am sure you know can get pretty hairy real quick.

I can't guarantee any performance metrics, but JSON SQL queries have always been pretty darn quick for me.

I also use JSON SQL queries for filtering when I want to do it client side. Table's client side filtering outside of table - #3 by bradlymathews

You can also use JSON SQL to mock events on almost any property of any component. Watched Inputs for JS queries

Rules of thumb:

  1. If it is too easy to bother with a JSON SQL query then use a transformer.
  2. Is it easy to do in SQL? Use a JSON SQL query. Note you can pass additionalScope to a JSON query or use i from ListViews so you can pass in parameters.
  3. If it is way too hard to figure out the SQL to do it, or SQL just can't do it then use a transformer.
  4. If 2. or 3. and you need to pass parameters using additionalScope or i, use a JS Query and return a result (or set a temp var.)
2 Likes