Files
mayfly-go/server/internal/db/application/meta.go
meilin.huang 85349df8a1 code review
2022-12-17 22:24:21 +08:00

33 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package application
// -----------------------------------元数据接口定义------------------------------------------
// 数据库元信息接口(表、列、获取表数据等元信息)
// 所有数据查出来直接用map接收注意不同数据库实现该接口返回的map中的key需要统一.
// 即: 使用别名统一即可。如table_name AS tableName
type DbMetadata interface {
// 获取表基础元信息
// 表名: tableName, 备注: tableComment
GetTables() []map[string]interface{}
// 获取指定表名的所有列元信息
// 表名: tableName, 列名: columnName, 列类型: columnType, 备注: columnComment, 是否可为null: nullable, 其他信息: extra
GetColumns(tableNames ...string) []map[string]interface{}
// 获取表主键字段名,没有主键标识则默认第一个字段
GetPrimaryKey(tablename string) string
// 获取表信息比GetTables获取更详细的表信息
GetTableInfos() []map[string]interface{}
// 获取表索引信息
GetTableIndex(tableName string) []map[string]interface{}
// 获取建表ddl
GetCreateTableDdl(tableName string) []map[string]interface{}
// 获取指定表的数据-分页查询
// @return columns: 列字段名result: 结果集error: 错误
GetTableRecord(tableName string, pageNum, pageSize int) ([]string, []map[string]interface{}, error)
}