prismaschema

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prismaschema lexes and parses Prisma schema files for the prisma plugin (tables, columns) and the env plugin (the env("…") names a schema reads). See https://cernly.dev/how/plugins/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsIdent

func IsIdent(c byte) bool

func LineOf

func LineOf(err error) int

func Unquote

func Unquote(s string) string

Types

type Block

type Block struct {
	Kind, Name string
	File       string
	Line, End  int
	Lines      []Line
}

func Parse

func Parse(file string, src []byte) ([]Block, error)

type Env

type Env struct {
	Name string
	Line int
}

Env is an environment variable a schema reads, and the line it is on.

func EnvNames

func EnvNames(src []byte) ([]Env, error)

EnvNames returns the env("NAME") calls of a schema (datasource url, directUrl, shadowDatabaseUrl, generator settings), in order. Comments are not tokens, so a call in a comment is not read.

type Line

type Line struct{ Toks []Token }

Line is one line of a block, its tokens.

func (Line) ArgsAfter

func (l Line) ArgsAfter(i int) string

ArgsAfter renders the parenthesised arguments that follow index i, for Unsupported("…").

func (Line) BlockAttr

func (l Line) BlockAttr(name string) string

BlockAttr reads @@map("x") / @@schema("x"): the string argument.

func (Line) FieldAttr

func (l Line) FieldAttr(name string) bool

FieldAttr reports a field attribute (@id, @unique, @relation).

func (Line) FieldAttrArg

func (l Line) FieldAttrArg(name string) string

FieldAttrArg reads @map("x") on a field line.

func (Line) Fields

func (l Line) Fields() []string

Fields reads @@id([a, b]): the field names of the first list argument.

func (Line) Native

func (l Line) Native() string

Native reads a field's native type: @db.VarChar(255) as VarChar(255).

type Token

type Token struct {
	Text string
	Line int
}

func Lex

func Lex(src []byte) ([]Token, error)

Jump to

Keyboard shortcuts

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