Prettify my query line

Hi, is there a way to make the where clauses prettier than have a bunch of ors?

${query[[
  from index.tag "task"
  where (state == "" or state == "NEXT" or state == "LATER" or state == "SUBTASK") 

You could create a function to check if the state is in a certain table:

Space Lua:

local function is_in(val, tab)
    for _, value in ipairs(tab) do
        if value == val then
            return true
        end
    end

    return false
end

Then use it as such:

${query[[
  from index.tag "task"
  where is_in(state, {"", "NEXT", "LATER", "SUBTASK"})
]]}
1 Like