---
tags: lua
date: "2026-11-09"
---
# Scripts Lua pour les rquêtes

```space-lua

-- priority: 100
q = q or {}

function q.today_events(d, n)
  local d = d or editor.getCurrentPageMeta().date
  local n = n or 10
  return query[[
    from t = index.tasks('event')
    where t.date and t.date == d
    order by t.hour asc
    limit n or 10
    select {
      REF = "[[" .. t.ref .. "]]",
      DONE = (
        t.done == true and "🟢" or
        t.done == false and "🔴"
      ),
      HOUR = t.hour,
      TEXT =  t.name
    } or "Aucun événement à afficher"
  ]]
end

function q.today_tasks(d, n)
  local d = d or editor.getCurrentPageMeta().date
  local n = n or 10
  return query[[
    from t = index.tasks('event')
    where t.done == false and t.date and t.date == d and not table.includes(t.tags, "event")
    order by t.tags asc
    limit n or 10
    select {
      REF = "[[" .. t.ref .. "]]",
      DATE = t.date,
      TEXT =  t.name,
      TAGS = t.tags,
    }
  ]]
end

```
