substance

package module
v0.0.0-...-559915d Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2019 License: AGPL-3.0 Imports: 1 Imported by: 2

README

substance

This project is a work in progress. This means the master branch is unstable and broken builds may occur.

Substance provides an interface for implementations extract schema data from a data provider (mysql, postgres, etc.).

SubstanceGen provides an interface for implementations to use data produced by Substance to generate code.

Status

Build Code coverage Report card Codebeat
Build Code coverage Report card Codebeat

Substance Supported Data Providers

  • MySQL/MariaDB
  • Postgres
  • Sqlite3
  • JSON planned

SubstanceGen Code Generators

Substancegen code generators:

  • GORM Generates CRUD functions from the database model
  • Go Struct Generates Go structs from the database model
  • graphql-go Generates source code for graphql-go
  • gqlscehma Generates graphql schema files

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentDatabaseName

func GetCurrentDatabaseName(dbType string, db *sql.DB) (string, error)

GetCurrentDatabaseName returns currrent database schema name as string

func Register

func Register(pluginName string, pluginInterface SubstanceProviderInterface)

Register registers a sbustance plugin which implements the Substance interface

Types

type ColumnConstraint

type ColumnConstraint struct {
	TableName      string
	ColumnName     string
	ConstraintType string
}

ColumnConstraint Struct to store column constraint types

func DescribeTableConstraints

func DescribeTableConstraints(dbType string, db *sql.DB, tableName string) ([]*ColumnConstraint, error)

DescribeTableConstraints returns all column constraints in a database table

type ColumnDescription

type ColumnDescription struct {
	DatabaseName string
	TableName    string
	PropertyName string
	PropertyType string
	KeyType      string
	DefaultValue string
	Nullable     bool
}

ColumnDescription Structure to store properties of each column in a table

func DescribeDatabase

func DescribeDatabase(dbType string, db *sql.DB) ([]*ColumnDescription, error)

DescribeDatabase returns tables in database

func DescribeTable

func DescribeTable(dbType string, db *sql.DB, tableName string) ([]*ColumnDescription, error)

DescribeTable returns columns of a table

type ColumnRelationship

type ColumnRelationship struct {
	TableName           string
	ColumnName          string
	ReferenceTableName  string
	ReferenceColumnName string
}

ColumnRelationship Structure to store relationships between tables

func DescribeTableRelationship

func DescribeTableRelationship(dbType string, db *sql.DB, tableName string) ([]*ColumnRelationship, error)

DescribeTableRelationship returns all foreign column references in database table

type QueryResult

type QueryResult struct {
	Rows     *sql.Rows
	Columns  []string
	Values   []interface{}
	ScanArgs []interface{}
	Err      error
}

QueryResult Struct to store results from ExecuteQuery

func ExecuteQuery

func ExecuteQuery(dbType string, db *sql.DB, tableName string, query string) QueryResult

ExecuteQuery executes a sql query with one or no tableName, specific to mysqlsubstnace and pgsqlsubstance

type SubstanceProviderInterface

type SubstanceProviderInterface interface {
	DatabaseName(dbType string, db *sql.DB) (string, error)
	DescribeDatabase(dbType string, db *sql.DB) ([]*ColumnDescription, error)
	DescribeTable(dbType string, db *sql.DB, tableName string) ([]*ColumnDescription, error)
	TableRelationships(dbType string, db *sql.DB, tableName string) ([]*ColumnRelationship, error)
	TableConstraints(dbType string, db *sql.DB, tableName string) ([]*ColumnConstraint, error)
	ToGoDataType(sqlType string) (string, error)
}

SubstanceProviderInterface

Directories

Path Synopsis
cmd
providers

Jump to

Keyboard shortcuts

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