const role = 'user';

const dbUsers = _db.query(
    `select user.id, user.uid, user.username, user.email, role.name "role"
    from user
        inner join role
            on user.role_id = role.id
    where role.name = ?`,
    role
);

const users = _val.list();
for (const dbUser of dbUsers) {
    users.add(
        _val.map()
        .set("uid", dbUser.getString("uid"))
        .set("username", dbUser.getString("username"))
        .set("email", dbUser.getString("email"))
        .set("role", dbUser.getString("role"))
    );
}


_out.json(users);