-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.eta
46 lines (34 loc) · 1.13 KB
/
template.eta
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
<% function printTable(db, table){ %>
<% const connection = [] %>
<% const relation = [] %>
<%= table %>: {
shape: sql_table
<% Object.keys(db[table]).forEach(function(column) { %>
<% if ( column === 'relations') { %>
<% db[table][column].forEach( function(val){ %>
<% relation.push(val) %>
<% }) %>
<% } else if ( typeof db[table][column] === 'object' ) { %>
<%= column %>: Object
<% connection.push(column) %>
<% } else { %>
<%= column %>: <%= db[table][column] %>
<% } %>
<% }) %>
}
<% relation.forEach( function(val){ %>
<%= table %> -> <%= val %>
<% }) %>
<% connection.forEach( function(val){ %>
<%= table %> -> <%= val %>
<% printTable(db[table], val)%>
<% }) %>
<% } %>
<% Object.keys(it.schema).forEach(function(database) { %>
<% console.log("The value of database is: " + database) %>
<%= database %>: {
<% Object.keys(it.schema[database]).forEach(function(table) { %>
<% printTable(it.schema[database], table) %>
<% }) %>
}
<% }) %>