我正在尝试这样做:
UPDATE subscribers
SET last_pushed_at = now()
FROM (
SELECT id
FROM subscribers
ORDER BY last_pushed_at ASC NULLS FIRST
LIMIT 5
) oldest
WHERE oldest.id = subscribers.id
RETURNING subscribers.username
这是我到目前为止所拥有的...可悲的是:
sq = from(s in Ztz.Subscriber,
select: {s.id},
order_by: [:asc_nulls_first],
limit: ^demand
)
subscribers = Repo.update_all(
from(oldest in subquery(sq),
set: [last_pushed_at: DateTime.utc_now()],
where: oldest.id == s2.id,
)
)