Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 节点-orm2上的左/右连接_Mysql_Node.js_Join_Node Orm2 - Fatal编程技术网

Mysql 节点-orm2上的左/右连接

Mysql 节点-orm2上的左/右连接,mysql,node.js,join,node-orm2,Mysql,Node.js,Join,Node Orm2,我正在我的节点开发中使用dresende/node-orm2-ORM。但是我需要做一些左/右连接,但是我在文档中找不到如何进行。我在尝试进行多个联接时也遇到问题 此代码: crModel.hasOne ('client', cliModel, { field: 'client_id' }); crModel.hasOne ('office', boModel, { field: 'bo_id' }); crModel.findByClient ({}).findByO

我正在我的节点开发中使用dresende/node-orm2-ORM。但是我需要做一些左/右连接,但是我在文档中找不到如何进行。我在尝试进行多个联接时也遇到问题

此代码:

crModel.hasOne ('client', cliModel, {

    field:  'client_id'
});

crModel.hasOne ('office', boModel, {

    field:  'bo_id'
});

crModel.findByClient ({}).findByOffice ({}).find ({

    client_id:  1,
    bo_id:      1
}, function () {

    console.log (arguments);
});
生成此查询:

SELECT `t1`.`cr_id`, `t1`.`cr_datetime`, `t1`.`credit_id`, `t1`.`gs_id`, `t1`.`cellphone_id`, `t1`.`bo_id`, `t1`.`client_id` FROM `CreditRequests` `t1` JOIN `BranchOffices` `t2` ON `t2`.`bo_id` = `t1`.`bo_id` WHERE `t1`.`client_id` = 1 AND `t1`.`bo_id` = 1

谢谢,很抱歉我的英语不好。

ORM的诀窍是设想这种关系,而不是让它工作的命令。与ORM2有很多联系-我将从那里开始。从文档中:

patient.getDoctors(function..)           // List of doctors
patient.addDoctors(docs, function...)    // Adds entries to join table
patient.setDoctors(docs, function...)    // Removes existing entries in join table, adds new ones
patient.hasDoctors(docs, function...)    // Checks if patient is associated to specified doctors
patient.removeDoctors(docs, function...) // Removes specified doctors from join table

doctor.getPatients(function..)
etc...

// You can also do:
patient.doctors = [doc1, doc2];
patient.save(...)