forked from goodybag/mongo-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query-types.js
67 lines (53 loc) · 1.31 KB
/
query-types.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var queryTypes = require('../lib/query-types');
queryTypes.add( 'select', [
'{with} select {expression} {distinct}'
, '{columns} {over} {table} {alias}'
, '{joins} {join} {innerJoin} {leftJoin} {leftOuterJoin} {fullOuterJoin} {crossOuterJoin}'
, '{where} {groupBy} {window} {order} {limit} {offset}'
].join(' '));
queryTypes.add(
'insert'
, '{with} insert into {table} {columns} {values} {expression} {returning}'
);
queryTypes.add(
'update'
, '{with} update {table} {values} {updates} {from} {where} {returning}'
);
queryTypes.add(
'delete'
, '{with} delete from {table} {where} {returning}'
);
queryTypes.add(
'remove'
, '{with} delete from {table} {alias} {where} {returning}'
);
queryTypes.add(
'create-table'
, '{with} create table {ifNotExists} {table} ({definition})'
);
queryTypes.add(
'drop-table'
, '{with} drop table {ifExists} {table} {cascade}'
);
queryTypes.add(
'alter-table'
, 'alter table {ifExists} {only} {table} {action}'
);
queryTypes.add(
'create-view'
, 'create {orReplace} {temporary} view {view} {columns} as {expression}'
);
queryTypes.add(
'union'
, '{with} {queries}'
);
queryTypes.add(
'intersect'
, '{with} {queries}'
);
queryTypes.add(
'except'
, '{with} {queries}'
);
queryTypes.add('function', '{function}( {expression} )');
queryTypes.add('expression', '{expression}');