Capabilities
Capabilities Iteration
Imported from the upstream Vibescript examples at capabilities/iteration.vibe and runnable in the browser today.
Source
capabilities/iteration.vibe
# vibe: 0.2
# uses: db
def total_raised_for_player(player_id)
total = money("0.00 USD")
db.each("ScoreEntry", where: { player_id: player_id }) do |entry|
total = total + entry[:amount]
end
total
end
def run
{
note: "This example requires the db capability which is injected by the host application.",
functions: ["total_raised_for_player"]
}
end
Output
Press run to execute run from this example.