forked from TokyoFarmer/node-sql-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoin.js
More file actions
36 lines (31 loc) · 781 Bytes
/
join.js
File metadata and controls
36 lines (31 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
var Node = require(__dirname);
var JoinNode = module.exports = Node.define({
type: 'JOIN',
constructor: function(subType, from, to) {
Node.call(this);
if (subType.type === 'JOIN') {
// implement copy constructor
var other = subType;
this.subType = other.subType;
this.from = other.from;
this.to = other.to;
this.on = other.on;
} else {
this.subType = subType;
this.from = from.toNode();
this.to = to.toNode();
}
},
on: function(node) {
var mutated = new JoinNode(this);
mutated.on = node;
return mutated;
},
join: function(other) {
return new JoinNode('INNER', this, other);
},
leftJoin: function(other) {
return new JoinNode('LEFT', this, other);
}
});