Documentation
¶
Index ¶
- func LoadSchemaFromPath(path string) (map[string]*schema.Schema, error)
- func ParseSchema(content string) (map[string]*schema.Schema, error)
- func ParseSchemaFile(filename string) (map[string]*schema.Schema, error)
- type ArrayExpression
- type Attribute
- type BlockAttribute
- type Converter
- func (c *Converter) Convert(prismaSchema *PrismaSchema) (map[string]*schema.Schema, error)
- func (c *Converter) GetDatabaseProvider() string
- func (c *Converter) GetDatabaseURL() string
- func (c *Converter) GetDatasource() *DatasourceStatement
- func (c *Converter) GetGenerator() *GeneratorStatement
- func (c *Converter) GetGeneratorProvider() string
- type DatasourceStatement
- type DotExpression
- type EnumStatement
- type EnumValue
- type Expression
- type Field
- type FieldType
- type FunctionCall
- type GeneratorStatement
- type Identifier
- type Lexer
- type ModelStatement
- type NamedArgument
- type Node
- type NumberLiteral
- type Parser
- type PrismaSchema
- type Property
- type Statement
- type StringLiteral
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadSchemaFromPath ¶ added in v0.6.0
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 ¶
ParseSchema parses Prisma schema content and returns schemas map
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
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 (*Converter) GetDatabaseProvider ¶
GetDatabaseProvider extracts the database provider from datasource
func (*Converter) GetDatabaseURL ¶
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 ¶
GetGeneratorProvider extracts the generator provider
type DatasourceStatement ¶
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 ¶
EnumStatement represents an enum definition
func (*EnumStatement) String ¶
func (es *EnumStatement) String() string
type Expression ¶
type Expression interface {
Node
// contains filtered or unexported methods
}
Expression represents an expression node
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 ¶
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
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 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 (*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
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 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 )