ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# loop方法遍历 loop循环适用于查询数据集`select()、selectForMap()`的结果输出,针对于返回结果List和map进行循环遍历 表达式使用 ```java List<RowData> select = Db.name("tg_task").where("status", 1).select(); Loop.forEach(select, new RowDataCallback<RowData, Integer>() { @Override public void onData(RowData data, Integer index) { data.set("qq","123"); } }); 或 Map<Integer, RowData> integerRowDataMap = Db.name("tg_task").where("status", 1).selectForMap(); Loop.forEach(integerRowDataMap, new RowDataCallback<RowData, Integer>() { @Override public void onData(RowData data, Integer index) { data.set("qq","123"); } }); ``` 运行结果 ```java { "code": 1, "msg": "success", "data": [ { "qq": "123", "id": "1" }, { "qq": "123", "id": "9" } ] } 或 { "code": 1, "msg": "success", "data": { "1": { "qq": "123", "id": "1" }, "2": { "qq": "123", "id": "2" } } } ```