Wiki source code of Rooms
Version 6.1 by Ricardo Julio Rodríguez Fernández on 2024/03/11 19:57
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{groovy}} | ||
2 | import groovy.sql.Sql | ||
3 | def sql = new Sql(services.igfaebbdddummyas.getConnection()) | ||
4 | def query = "SELECT | ||
5 | JSON_ARRAYAGG(room_data) AS all_data | ||
6 | FROM ( | ||
7 | SELECT | ||
8 | JSON_OBJECT( | ||
9 | 'id', room_id, | ||
10 | 'title', room_title, | ||
11 | 'color', room_color, | ||
12 | 'item', JSON_ARRAYAGG(JSON_OBJECT('title', person)) | ||
13 | ) AS room_data | ||
14 | FROM | ||
15 | json | ||
16 | GROUP BY | ||
17 | room_id, room_title, room_color | ||
18 | ) AS room_data;" | ||
19 | |||
20 | println(query.get(0).testid.toString()) | ||
21 | |||
22 | def countitems = appitems.size() println(countitems) | ||
23 | |||
24 | assert countitems == query.get(0).testid | ||
25 | sql.close() | ||
26 | {{/groovy}} |