我正在尝试通过 node-mysql 模块从 Node.js 应用程序中的 Mysql 获取 JSON 类型数据。
在数据库上运行此查询:
SELECT countries.id,
countries.country_name,
Json_object("start", start_port, "end", end_port)
ten_minutes,
Json_object("start", start_port + 10000, "end", end_port + 10000)
one_minutes,
Json_object("start", start_port + 20000, "end", end_port + 20000)
thirty_minutes
FROM countries
JOIN countries_port_ranges
ON country_id = countries.id;
Run Code Online (Sandbox Code Playgroud)
返回:
1 Afghanistan {"start": 8000, "end": 8029} {"start": 18000, "end": 18029} {"start": 28000, "end": 28029}
2 Albania {"start": 8030, "end": 8059} {"start": 18030, "end": 18059} {"start": 28030, "end": 28059}
3 Algeria {"start": 8060, "end": 8089} …Run Code Online (Sandbox Code Playgroud)