er

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package er is mermaid entity relationship diagram builder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	// Type is the type of the attribute.
	Type string
	// Name is the name of the attribute.
	Name string
	// IsPrimaryKey is the flag that indicates whether the attribute is a primary key.
	IsPrimaryKey bool
	// IsForeignKey is the flag that indicates whether the attribute is a foreign key.
	IsForeignKey bool
	// IsUniqueKey is the flag that indicates whether the attribute is a unique key.
	IsUniqueKey bool
	// Comment is the comment of the attribute.
	Comment string
}

Attribute is a attribute of the entity.

type Diagram

type Diagram struct {
	// contains filtered or unexported fields
}

Diagram is a entity relationship diagram builder.

func NewDiagram

func NewDiagram(w io.Writer, opts ...Option) *Diagram

NewDiagram returns a new Diagram.

func (*Diagram) Build

func (d *Diagram) Build() error

Build writes the entity relationship body to the output destination.

func (*Diagram) NoRelationship

func (d *Diagram) NoRelationship(e Entity) *Diagram

NoRelationship adds an entity that has no relationships.

func (*Diagram) Relationship

func (d *Diagram) Relationship(leftE, rightE Entity, leftR, rightR Relationship, identidy Identify, comment string) *Diagram

Relationship is a relationship of entity relationship. leftE: left entity rightE: right entity leftR: left relationship. You choice from Relationship constants (e.g. ZeroToOneRelationship) rightR: right relationship. You choice from Relationship constants (e.g. ZeroToOneRelationship) identidy: identify of the relationship. You choice from Identify constants (e.g. Identifying)

func (*Diagram) String

func (d *Diagram) String() string

String returns the entity relationship diagram body.

type Entity

type Entity struct {
	// Name is the name of the entity.
	Name string
	// Attributes is the attributes of the entity.
	Attributes []*Attribute
}

Entity is a entity of entity relationship.

func NewEntity

func NewEntity(name string, attrs []*Attribute) Entity

NewEntity returns a new Entity.

type Identify

type Identify bool

Identify is a type that represents the relationship between entities in an entity relationship diagram. Relationships may be classified as either identifying or non-identifying and these are rendered with either solid or dashed lines respectively.

const (
	// Identifying is a constant that represents an identifying relationship.
	// It represents "--" in the entity relationship diagram.
	Identifying Identify = true
	// NonIdentifying is a constant that represents a non-identifying relationship.
	// It represents ".." in the entity relationship diagram.
	NonIdentifying Identify = false
)

type Option

type Option func(*config)

Option sets the options for the PieChart struct.

type Relationship

type Relationship string

Relationship is a type that represents the relationship between entities.

const (
	// ZeroToOneRelationship is a constant that represents a zero to one relationship.
	// e.g. "|o" or "o|"
	ZeroToOneRelationship Relationship = "zero_to_one"
	// ExactlyOneRelationship is a constant that represents an exactly one relationship.
	// e.g. "||"
	ExactlyOneRelationship Relationship = "exactly_one"
	// ZeroToMoreRelationship is a constant that represents a zero to more relationship.
	// e.g. "}o" or "o{}"
	ZeroToMoreRelationship Relationship = "zero_to_more"
	// OneToMoreRelationship is a constant that represents a one to more relationship.
	// e.g. "}|" or "|}"
	OneToMoreRelationship Relationship = "one_to_more"
)

Jump to

Keyboard shortcuts

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