add json format to route /admin/get-all-users
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b5c7a186c7
commit
6b76803443
@ -1,8 +1,18 @@
|
||||
import 'dart:convert';
|
||||
import 'package:postgres/postgres.dart';
|
||||
|
||||
class DB2API {
|
||||
static String map2Json(PostgreSQLResult data) {
|
||||
return jsonEncode(data);
|
||||
static String allUsersToJson(PostgreSQLResult data) {
|
||||
String body = "";
|
||||
int count = 0;
|
||||
for (final row in data) {
|
||||
body += userToString(row[0], row[1], row[2]);
|
||||
count++;
|
||||
if (count != data.length) body += ",";
|
||||
}
|
||||
return "[$body]";
|
||||
}
|
||||
|
||||
static String userToString(String email, String hash, String salt) {
|
||||
return """{"email" : "$email", "hash" : "$hash", "salt" : "$salt"}""";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue