Help us shape the future of Go! Take the 2026 Go Developer Survey

prisma

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSchemaFromPath added in v0.6.0

func LoadSchemaFromPath(path string) (map[string]*schema.Schema, error)

LoadSchemaFromPath loads Prisma schemas from a file or directory This function supports loading a single .prisma file or all .prisma files from a directory

func ParseSchema

func ParseSchema(content string) (map[string]*schema.Schema, error)

ParseSchema parses Prisma schema content and returns schemas map

func ParseSchemaFile

func ParseSchemaFile(filename string) (map[string]*schema.Schema, error)

ParseSchemaFile reads and parses Prisma schema file

Types

type ArrayExpression

type ArrayExpression struct {
	Elements []Expression
}

ArrayExpression represents an array expression

func (*ArrayExpression) String

func (ae *ArrayExpression) String() string

type Attribute

type Attribute struct {
	Name string
	Args []Expression
}

Attribute represents a field attribute

func (*Attribute) String

func (a *Attribute) String() string

type BlockAttribute

type BlockAttribute struct {
	Name string
	Args []Expression
}

BlockAttribute represents a block-level attribute (@@)

func (*BlockAttribute) String

func (ba *BlockAttribute) String() string

type Converter

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

Converter converts Prisma AST to ReORM Schema objects

func NewConverter

func NewConverter() *Converter

NewConverter creates a new converter instance

func (*Converter) Convert

func (c *Converter) Convert(prismaSchema *PrismaSchema) (map[string]*schema.Schema, error)

Convert converts a Prisma schema AST to ReORM schemas

func (*Converter) GetDatabaseProvider

func (c *Converter) GetDatabaseProvider() string

GetDatabaseProvider extracts the database provider from datasource

func (*Converter) GetDatabaseURL

func (c *Converter) GetDatabaseURL() string

GetDatabaseURL extracts the database URL from datasource

func (*Converter) GetDatasource

func (c *Converter) GetDatasource() *DatasourceStatement

GetDatasource returns the datasource configuration

func (*Converter) GetGenerator

func (c *Converter) GetGenerator() *GeneratorStatement

GetGenerator returns the generator configuration

func (*Converter) GetGeneratorProvider

func (c *Converter) GetGeneratorProvider() string

GetGeneratorProvider extracts the generator provider

type DatasourceStatement

type DatasourceStatement struct {
	Name       string
	Properties []*Property
}

DatasourceStatement represents a datasource definition

func (*DatasourceStatement) String

func (ds *DatasourceStatement) String() string

type DotExpression

type DotExpression struct {
	Left  Expression
	Right string
}

DotExpression represents a dot notation expression (obj.property)

func (*DotExpression) String

func (de *DotExpression) String() string

type EnumStatement

type EnumStatement struct {
	Name   string
	Values []*EnumValue
}

EnumStatement represents an enum definition

func (*EnumStatement) String

func (es *EnumStatement) String() string

type EnumValue

type EnumValue struct {
	Name       string
	Attributes []*Attribute
}

EnumValue represents an enum value with optional mapping

type Expression

type Expression interface {
	Node
	// contains filtered or unexported methods
}

Expression represents an expression node

type Field

type Field struct {
	Name       string
	Type       *FieldType
	Optional   bool
	List       bool
	Attributes []*Attribute
}

Field represents a field in a model

func (*Field) String

func (f *Field) String() string

type FieldType

type FieldType struct {
	Name string
}

FieldType represents a field type

func (*FieldType) String

func (ft *FieldType) String() string

type FunctionCall

type FunctionCall struct {
	Name string
	Args []Expression
}

FunctionCall represents a function call expression

func (*FunctionCall) String

func (fc *FunctionCall) String() string

type GeneratorStatement

type GeneratorStatement struct {
	Name       string
	Properties []*Property
}

GeneratorStatement represents a generator definition

func (*GeneratorStatement) String

func (gs *GeneratorStatement) String() string

type Identifier

type Identifier struct {
	Value string
}

Identifier represents an identifier expression

func (*Identifier) String

func (i *Identifier) String() string

type Lexer

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

Lexer represents the lexer

func NewLexer

func NewLexer(input string) *Lexer

New creates a new lexer instance

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

NextToken scans the input and returns the next token

type ModelStatement

type ModelStatement struct {
	Name            string
	Fields          []*Field
	BlockAttributes []*BlockAttribute
}

ModelStatement represents a model definition

func (*ModelStatement) String

func (ms *ModelStatement) String() string

type NamedArgument

type NamedArgument struct {
	Name  string
	Value Expression
}

NamedArgument represents a named argument expression (key: value)

func (*NamedArgument) String

func (na *NamedArgument) String() string

type Node

type Node interface {
	String() string
}

Node represents an AST node

type NumberLiteral

type NumberLiteral struct {
	Value string
}

NumberLiteral represents a number literal expression

func (*NumberLiteral) String

func (nl *NumberLiteral) String() string

type Parser

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

Parser represents the parser

func NewParser

func NewParser(lexer *Lexer) *Parser

New creates a new parser instance

func (*Parser) Errors

func (p *Parser) Errors() []string

Errors returns parsing errors

func (*Parser) ParseSchema

func (p *Parser) ParseSchema() *PrismaSchema

ParseSchema parses the schema and returns AST

type PrismaSchema

type PrismaSchema struct {
	Statements []Statement
}

PrismaSchema represents the root of the AST

func (*PrismaSchema) String

func (ps *PrismaSchema) String() string

type Property

type Property struct {
	Name  string
	Value Expression
}

Property represents a property in datasource/generator

func (*Property) String

func (p *Property) String() string

type Statement

type Statement interface {
	Node
	// contains filtered or unexported methods
}

Statement represents a statement node

type StringLiteral

type StringLiteral struct {
	Value string
}

StringLiteral represents a string literal expression

func (*StringLiteral) String

func (sl *StringLiteral) String() string

type Token

type Token struct {
	Type    TokenType
	Literal string
	Line    int
	Column  int
}

Token represents a token

func (Token) String

func (t Token) String() string

String returns string representation of Token

type TokenType

type TokenType int

TokenType represents the type of token

const (
	// Special tokens
	ILLEGAL TokenType = iota
	EOF
	WHITESPACE
	COMMENT

	// Identifiers and literals
	IDENT  // model, field names
	STRING // "string literals"
	NUMBER // 123

	// Keywords
	MODEL
	ENUM
	DATASOURCE
	GENERATOR

	// Types
	INT
	STRING_TYPE
	BOOLEAN
	DATETIME
	JSON
	FLOAT
	DECIMAL

	// Operators and delimiters
	LBRACE   // {
	RBRACE   // }
	LBRACKET // [
	RBRACKET // ]
	LPAREN   // (
	RPAREN   // )
	AT       // @
	BLOCK_AT // @@
	QUESTION // ?
	COMMA    // ,
	EQUALS   // =
	COLON    // :
	DOT      // .

	// Attribute functions
	DEFAULT
	AUTOINCREMENT
	NOW
	UUID
	ENV
	UPDATEDAT
	CUID
	DB
	TRUE
	FALSE
	UNIQUE
	MAP
	INDEX
	ID
	TEXT
	VARCHAR
	MONEY
	JSONB
	UUID_TYPE
	TIMESTAMP
	DATE_TYPE
	TIME_TYPE
	DECIMAL_TYPE
	DOUBLEPRECISION
	REAL
	SMALLINT
	BIGINT_TYPE
	SERIAL
	BIGSERIAL
	CHAR
	INET
	BIT
	VARBIT
	XML

	// Referential actions
	CASCADE
	RESTRICT
	NOACTION
	SETNULL
	SETDEFAULT
	ONDELETE
	ONUPDATE
	DBGENERATED
)

func (TokenType) String

func (t TokenType) String() string

String returns string representation of TokenType

Jump to

Keyboard shortcuts

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