mirror of
https://github.com/vran-dev/databasir.git
synced 2025-08-08 17:32:14 +08:00
feature: support export document (#11)
* feat: add document export api * feat: update frontend resource
This commit is contained in:
@@ -1,40 +1,45 @@
|
||||
# ${meta.databaseName}
|
||||
| | |
|
||||
| --------------- | ---- |
|
||||
| Database name | |
|
||||
| Product name | |
|
||||
| Product version | |
|
||||
|
||||
| seq | name | comment |
|
||||
| ---- | --------------- | ------ |
|
||||
## Overview
|
||||
| | name | type | comment |
|
||||
| ---- | --------------- | ------ | ------ |
|
||||
<#list meta.tables as table>
|
||||
| ${table_index+1} | [${table.name}](#${table.name}) | ${table.comment!'N/A'} |
|
||||
| ${table_index+1} | [${table.name}](#${table.name}) | ${table.type} | ${table.comment!'N/A'} |
|
||||
</#list>
|
||||
|
||||
<#if config.renderTables>
|
||||
<#list meta.tables as table>
|
||||
## ${table.name}
|
||||
|
||||
## ${table.name}
|
||||
<#if config.renderColumns>
|
||||
### Columns
|
||||
### Columns
|
||||
|
||||
| seq | name | type | nullable | auto increment| default | comment |
|
||||
| ---- | ------ | ------ | ------ | -------- | ------ | ------ |
|
||||
| | name | type | primary Key | nullable | auto increment| default | comment |
|
||||
| --- | ---- | ---- | ----------- | -------- | ------------- | ------- | ------- |
|
||||
<#list table.columns as column>
|
||||
| ${column_index+1} | ${column.name} | ${column.type} | ${column.isNullable?then('YES','NO')} | ${column.isAutoIncrement?then('YES', 'NO')} | ${column.isNullable?then(column.defaultValue!'NULL', column.defaultValue!'')} | ${column.comment!''} |
|
||||
| ${column_index+1} | ${column.name} | ${column.type} | ${column.isPrimaryKey?then('YES','NO')} | ${column.nullable } | ${column.autoIncrement} | ${column.defaultValue!'NULL'} | ${column.comment!''} |
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
<#if config.renderIndexes>
|
||||
<#if config.renderIndexes>
|
||||
### Indexes
|
||||
|
||||
| seq | name | unique | primary key | columns |
|
||||
| ---- | ---- | -------- | -------- | ------ |
|
||||
| | name | unique | columns |
|
||||
| --- | ---- | ------ | ------- |
|
||||
<#list table.indexes as index>
|
||||
| ${index_index+1} | ${index.name} | ${index.isUniqueKey?then('YES', 'NO')} | ${index.isPrimaryKey?then('YES','NO')} | ${index.columnNames?join(', ')} |
|
||||
| ${index_index+1} | ${index.name} | ${index.isUniqueKey?then('YES', 'NO')} | ${index.columnNames?join(', ')} |
|
||||
</#list>
|
||||
</#if>
|
||||
|
||||
<#if config.renderTriggers>
|
||||
### Triggers
|
||||
|
||||
| seq | name | timing | statement | created |
|
||||
| ---- | ---- | -------- | --------- | -------- |
|
||||
| | name | timing | statement | created |
|
||||
| --- | ---- | ------ | --------- | ------- |
|
||||
<#list table.triggers as trigger>
|
||||
| ${trigger_index} | ${trigger.name} | ${trigger.timing + " " + trigger.manipulation } | ${trigger.statement?replace("\n", "<br>")?replace("\r", " ")} | ${trigger.createAt} |
|
||||
</#list>
|
||||
|
@@ -13,10 +13,10 @@ public class App {
|
||||
|
||||
@Test
|
||||
public void testRenderAsMarkdown() throws SQLException, ClassNotFoundException {
|
||||
try (FileOutputStream out = new FileOutputStream("user.md")) {
|
||||
try (FileOutputStream out = new FileOutputStream("demo.md")) {
|
||||
Connection connection = getJdbcConnection();
|
||||
Databasir databasir = Databasir.of();
|
||||
DatabaseMeta doc = databasir.get(connection, "user").orElseThrow();
|
||||
DatabaseMeta doc = databasir.get(connection, "demo").orElseThrow();
|
||||
databasir.renderAsMarkdown(doc, out);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
Reference in New Issue
Block a user