model

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package model contains structs to represent the information extracted from a database, like table names, view names, column names, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	SchemaName   string
	EntityName   string
	Name         string
	DataType     string
	Comment      string
	IsPrimaryKey bool
	IsForeignKey bool
}

A representation of a database column.

Column contains data that can be extracted from the database. Main data is the name, type and comment. The rest is to be able to identify the Entity it belongs to.

type DatabaseDescription

type DatabaseDescription struct {
	Schemas []Schema
}

A container for the different Schemas for which descriptions where extracted.

DatabaseDescription contains a slice of `Schema`.

func (DatabaseDescription) String

func (d DatabaseDescription) String() string

Returns a string representation of the DatabaseDescription struct.

type Entity

type Entity struct {
	SchemaName string
	Name       string
	EntityType string
	Columns    []Column
	Relations  []Relation
	Comment    string
}

A representation of a database entity (table, view, for example).

Entity struct contains data that can be extracted from the database, like the name and the comment. It also has a slice of Column.

func (Entity) String

func (e Entity) String() string

Returns a string representation of the Entity struct.

type Relation added in v1.0.3

type Relation struct {
	SchemaName          string
	EntityName          string
	RelationName        string
	ColumnName          string
	ForeignEntitySchema string
	ForeignEntityName   string
	ForeignColumnName   string
}

A representation of a relation between 2 entities.

The Relation struct represents data about a foreign key.

type Schema

type Schema struct {
	Name     string
	Entities []Entity
}

A container for entities descritpions in the database.

Schema struct contains the name of the schema (or namespace) and the slice of Entity that belong to it.

func (Schema) GetEntitiesByType

func (s Schema) GetEntitiesByType(entityType string) []Entity

Helper function to filter entities by type ("view", "table")

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL