readers

package
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package readers provides interfaces and implementations for reading database schemas from various input formats and data sources.

Overview

The readers package defines a common Reader interface that all format-specific readers implement. This allows RelSpec to read database schemas from multiple sources including:

  • Live databases (PostgreSQL, SQLite)
  • Schema definition files (DBML, DCTX, DrawDB, GraphQL)
  • ORM model files (GORM, Bun, Drizzle, Prisma, TypeORM)
  • Data interchange formats (JSON, YAML)

Architecture

Each reader implementation is located in its own subpackage (e.g., pkg/readers/dbml, pkg/readers/pgsql) and implements the Reader interface, supporting three levels of granularity:

  • ReadDatabase() - Read complete database with all schemas
  • ReadSchema() - Read single schema with all tables
  • ReadTable() - Read single table with all columns and metadata

Usage

Readers are instantiated with ReaderOptions containing source-specific configuration:

// Read from file
reader := dbml.NewReader(&readers.ReaderOptions{
    FilePath: "schema.dbml",
})
db, err := reader.ReadDatabase()

// Read from database
reader := pgsql.NewReader(&readers.ReaderOptions{
    ConnectionString: "postgres://user:pass@localhost/mydb",
})
db, err := reader.ReadDatabase()

Supported Formats

  • dbml: Database Markup Language files
  • dctx: DCTX schema files
  • drawdb: DrawDB JSON format
  • graphql: GraphQL schema definition language
  • json: JSON database schema
  • yaml: YAML database schema
  • gorm: Go GORM model structs
  • bun: Go Bun model structs
  • drizzle: TypeScript Drizzle ORM schemas
  • prisma: Prisma schema language
  • typeorm: TypeScript TypeORM entities
  • pgsql: PostgreSQL live database introspection
  • sqlite: SQLite database files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader interface {
	// ReadDatabase reads and parses the input, returning a Database model
	ReadDatabase() (*models.Database, error)

	// ReadSchema reads and parses the input, returning a Schema model
	ReadSchema() (*models.Schema, error)

	// ReadTable reads and parses the input, returning a Table model
	ReadTable() (*models.Table, error)
}

Reader defines the interface for reading database specifications from various input formats at different granularity levels

type ReaderOptions

type ReaderOptions struct {
	// FilePath is the path to the input file (if applicable)
	FilePath string

	// ConnectionString is the database connection string (for DB readers)
	ConnectionString string

	// Additional options can be added here as needed
	Metadata map[string]interface{}
}

ReaderOptions contains common options for readers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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