generator

package
v0.0.0-...-0cffe04 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package generator acts as a prisma generator

Index

Constants

View Source
const DefaultPackageName = "db"

Variables

This section is empty.

Functions

func Run

func Run(input *Root) error

Run invokes the generator, which builds the templates and writes to the specified output file.

Types

type BinaryPaths

type BinaryPaths struct {
	// MigrationEngine (optional)
	MigrationEngine map[string]string `json:"migrationEngine"` // key target, value path
	// QueryEngine (optional)
	QueryEngine map[string]string `json:"queryEngine"`
	// IntrospectionEngine (optional)
	IntrospectionEngine map[string]string `json:"introspectionEngine"`
}

BinaryPaths holds the information of the paths to the Prisma binaries.

type Config

type Config struct {
	Package types.String `json:"package"`
}

Config describes the options for the Prisma Client Go generator

type ConnectorType

type ConnectorType string

ConnectorType describes the Database of this generator.

const (
	ConnectorTypeMySQL      ConnectorType = "mysql"
	ConnectorTypeMongo      ConnectorType = "mongo"
	ConnectorTypeSQLite     ConnectorType = "sqlite"
	ConnectorTypePostgreSQL ConnectorType = "postgresql"
)

ConnectorType values

type Datasource

type Datasource struct {
	Name          types.String  `json:"name"`
	ConnectorType ConnectorType `json:"connectorType"`
	URL           EnvValue      `json:"url"`
	Config        interface{}   `json:"config"`
}

Datasource describes a Prisma data source of any database type.

type EnvValue

type EnvValue struct {
	// FromEnvVar (optional)
	FromEnvVar string `json:"fromEnvVar"`
	Value      string `json:"value"`
}

EnvValue contains a string value and optionally information if, and if yes from where, an env var is used for this value.

type Generator

type Generator struct {
	// Output (optional) holds the file path of where the client gets generated in.
	Output        string       `json:"output"`
	Name          types.String `json:"name"`
	Provider      types.String `json:"provider"`
	Config        Config       `json:"config"`
	BinaryTargets []string     `json:"binaryTargets"`
	// PinnedBinaryTarget (optional)
	PinnedBinaryTarget string `json:"pinnedBinaryTarget"`
}

Generator describes a generator defined in the Prisma schema.

type Root

type Root struct {
	Generator       Generator     `json:"generator"`
	OtherGenerators []Generator   `json:"otherGenerators"`
	SchemaPath      string        `json:"schemaPath"`
	DMMF            dmmf.Document `json:"DMMF"`
	Datasources     []Datasource  `json:"datasources"`
	// Datamodel provides the raw string of the Prisma datamodel.
	Datamodel string `json:"datamodel"`
	// BinaryPaths (optional)
	BinaryPaths BinaryPaths `json:"binaryPaths"`
}

Root describes the generator output root.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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