GraphQL 2019(3)Connect to MySQL
A nice example here
https://github.com/YuLeven/nodejs-graphql-mysql-example
Map the JSON
https://gist.github.com/microbial/b99af0a7eb11cb680c14
Lodash Documents
https://lodash.com/docs/4.17.15#keys
This project is really nice and useful
https://github.com/cheedbrands/async-mysql-wrapper
https://github.com/luohuazju/async-mysql-wrapper
https://github.com/luohuazju/xpmysql
https://github.com/baimeidaxia/xpmysql
We can add the mapping in DAO
const {Repository} = require('async-mysql-wrapper');
class EmployeeInfoDAO extends Repository {
constructor() {
super('employee_info', 'id', {
'gmt_create': 'gmtCreate',
'gmt_modified': 'gmtModified',
'employee_id': 'employeeID',
'rank_id': 'rankID',
'supervisor_id': 'supervisorID',
'tutor_id': 'tutorID'
})
}
async loadAllIDAndSupervisor() {
const query = `SELECT id, supervisor_id FROM ?? `;
return await this.selectList(query, [this.tableName]);
}
}
module.exports = new EmployeeInfoDAO();
We can use the default methods in service layer
const employeeID = employeeItem.id;
const employee = await EmployeeDAO.selectOneById(employeeID);
console.log("Employee:" + JSON.stringify(employee));
const rank = await RankDAO.selectOneById(employee.rankID);
console.log("Rank:" + JSON.stringify(rank));
const productInfos = await ProductInfoDAO.selectListSimple(
{
params: {
productID: item.productID,
rankID: employee.rankID
}
});
const productInfo = _.head(productInfos);
References:
https://github.com/mysqljs/mysql#readme
https://github.com/YuLeven/nodejs-graphql-mysql-example
分享到:
相关推荐
mysql的连接问题,重启电脑登录不上mysql的问题
Host 主机名 is not allowed to connect the mysql server 原因:没有授权远程访问mysql 解决方法: cmd 中运行mysql -u root -p(如果报mysql 不是内部或外部命令,找到安装mysql对应的bin文件夹运行mysql.exe,...
解决Can’t connect to MySQL server on ‘localhost’ (10048), 一般见于使用mysql的windows 2003服务器. 错误的出现的原因: 应用程序需要快速释放和创建新连接, 但是由于 TIME_WAIT 中存在的连接超过默认值,导致...
With this script you can connect the php with the MySQL database.
How to connect with VB to Mysql database
Navicat premium连接mysql时出现2003-Can't connect to MySql server on 'localhost'(10061)错误
让人纠结了一把…… 代码如下:zhouqian@zhou:~$ mysqlERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)网上好多的解决办法,可是每个人的实际情况...
代码如下:Could not connect: Can’t connect to MySQL server on ‘MYSQL.SERVER’ (13) 无论如何修改MySQL的授权,或者调整php.ini中关于MySQL的设置,或者修改MySQL的监听网口,都无法解决。 而如果用命令行人工...
Can't connect to MySQL server on 'localhost' (10061)解决方法,需要的朋友可以参考下。
最近在学习Django框架,于是在windows系统上搭建了Django环境,并使用虚拟机ubuntu系统上安装的mysql作为项目的远程数据库,前几天一直用得好好的,今天在虚拟机上连接数据库时,出现了如下错误: 本地数据库没法...
?php $link=mysql_connect(‘localhost’,’root’,... 运行后报错 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ 但在 命令行中能进入mysql [root@localhost local]# mysql -u root -p E
代码如下:Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0 很明显这是连接初始化阶段就丢失了连接的错误。 google半天大多是说的注释掉配置文件中 bind-address = ...
MySQL报错Can’t connect to MySQL server on ‘localhost’ (10061)等问题的解决办法 今天把数据库卸载安装了一下,遇到了如下问题,网上看了很多解决方法,但是诸多不顺,问题一个接一个。。。。。。最后,将我...
This book also introduces you to Apollo Client, a popular framework you can use to connect GraphQL to your user interface. Explore graph theory and review popular graph examples in use today Learn...
PHP webservice SOAP解决Could not connect to host
很多同学都说在用Eclispe出现“cannot connect to VM” 。现在给你们解决!
ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111) 解决办法: /usr/local/mysql/bin/mysqladmin -u root > -S /var/lib/mysql/mysql.sock password 'your.passwd' ...
NULL 博文链接:https://rayoo.iteye.com/blog/1973032
如果你想连接你的mysql的时候发生这个错误: 代码如下: ERROR 1130: Host ‘192.168.1.3’ is not allowed to connect to this MySQL server 解决方法: 1。 改表法。可能是你的帐号不允许从远程登陆,只能在...
"Host 'localhost' is not allowed to connect to this MySQL server" 的原因及解决办法