drawdb

package
v1.0.34 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: 8 Imported by: 0

README

DrawDB Reader

Reads DrawDB schema files and extracts database schema information.

Overview

The DrawDB Reader parses JSON files exported from DrawDB (a free online database design tool) and converts them into RelSpec's internal database model representation.

Features

  • Parses DrawDB JSON format
  • Extracts tables, fields, and relationships
  • Supports DrawDB-specific metadata
  • Preserves visual layout information

Usage

Basic Example
package main

import (
    "fmt"
    "git.warky.dev/wdevs/relspecgo/pkg/readers"
    "git.warky.dev/wdevs/relspecgo/pkg/readers/drawdb"
)

func main() {
    options := &readers.ReaderOptions{
        FilePath: "/path/to/diagram.json",
    }

    reader := drawdb.NewReader(options)
    db, err := reader.ReadDatabase()
    if err != nil {
        panic(err)
    }

    fmt.Printf("Found %d schemas\n", len(db.Schemas))
}
CLI Example
# Read DrawDB export and convert to JSON schema
relspec --input drawdb --in-file diagram.json --output json --out-file schema.json

# Convert DrawDB design to GORM models
relspec --input drawdb --in-file design.json --output gorm --out-file models.go

Example DrawDB Export

DrawDB exports database designs as JSON files containing:

{
  "tables": [
    {
      "id": "1",
      "name": "users",
      "fields": [
        {
          "name": "id",
          "type": "BIGINT",
          "primary": true,
          "autoIncrement": true
        },
        {
          "name": "username",
          "type": "VARCHAR",
          "size": 50,
          "notNull": true,
          "unique": true
        }
      ]
    }
  ],
  "relationships": [
    {
      "source": "posts",
      "target": "users",
      "type": "many-to-one"
    }
  ]
}

Notes

  • DrawDB is a free online database designer at drawdb.vercel.app
  • Export format preserves visual design metadata
  • Useful for converting visual designs to code
  • Schema defaults to public

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader implements the readers.Reader interface for DrawDB JSON format

func NewReader

func NewReader(options *readers.ReaderOptions) *Reader

NewReader creates a new DrawDB reader with the given options

func (*Reader) ReadDatabase

func (r *Reader) ReadDatabase() (*models.Database, error)

ReadDatabase reads and parses DrawDB JSON input, returning a Database model

func (*Reader) ReadSchema

func (r *Reader) ReadSchema() (*models.Schema, error)

ReadSchema reads and parses DrawDB JSON input, returning a Schema model

func (*Reader) ReadTable

func (r *Reader) ReadTable() (*models.Table, error)

ReadTable reads and parses DrawDB JSON input, returning a Table model

Jump to

Keyboard shortcuts

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