driver

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TableNamesFromFilter added in v0.23.0

func TableNamesFromFilter(models []Model, tableFilter drivers.Filter) []string

Types

type Config

type Config struct {
	// List of tables that will be included. Others are ignored
	Only map[string][]string
	// List of tables that will be should be ignored. Others are included
	Except map[string][]string

	// The name you wish to assign to your generated models package
	Pkgname   string
	NoFactory bool `yaml:"no_factory"`
}

type DBInfo

type DBInfo = drivers.DBInfo[Extra]

type Datamodel

type Datamodel struct {
	Models []Model `json:"models"`
	Enums  []struct {
		Name   string      `json:"name"`
		Values []EnumValue `json:"values"`
		// DBName (optional)
		DBName string `json:"dBName"`
	} `json:"enums"`
}

func (Datamodel) ModelByName

func (d Datamodel) ModelByName(name string) Model

type Document

type Document struct {
	Datamodel Datamodel `json:"datamodel"`
}

Document describes the root of the AST.

type EnumValue

type EnumValue struct {
	Name string `json:"name"`
	// DBName (optional)
	DBName string `json:"dBName"`
}

EnumValue contains detailed information about an enum type.

type Extra

type Extra struct {
	Provider Provider
}

type Field

type Field struct {
	Kind       FieldKind `json:"kind"`
	Name       string    `json:"name"`
	IsRequired bool      `json:"isRequired"`
	IsList     bool      `json:"isList"`
	IsUnique   bool      `json:"isUnique"`
	IsReadOnly bool      `json:"isReadOnly"`
	IsID       bool      `json:"isId"`
	Type       string    `json:"type"`
	// DBName (optional)
	DBName        string `json:"dBName"`
	IsGenerated   bool   `json:"isGenerated"`
	IsUpdatedAt   bool   `json:"isUpdatedAt"`
	Documentation string `json:"documentation"`
	// RelationFromFields (optional)
	RelationFromFields []string `json:"relationFromFields"`
	// RelationToFields (optional)
	RelationToFields []string `json:"relationToFields"`
	// RelationOnDelete (optional)
	RelationOnDelete string `json:"relationOnDelete"`
	// RelationName (optional)
	RelationName string `json:"relationName"`
	// HasDefaultValue
	HasDefaultValue bool         `json:"hasDefaultValue"`
	Default         fieldDefault `json:"default"`
}

Field describes properties of a single model field.

type FieldKind

type FieldKind string

FieldKind describes a scalar, object or enum.

const (
	FieldKindScalar FieldKind = "scalar"
	FieldKindObject FieldKind = "object"
	FieldKindEnum   FieldKind = "enum"
)

FieldKind values

type Interface

type Interface = drivers.Interface[Extra]

func New

func New(config Config, dialect string, provider Provider, datamodel Datamodel) Interface

type Model

type Model struct {
	Name          string        `json:"name"`
	IsEmbedded    bool          `json:"isEmbedded"`
	DBName        string        `json:"dbName"`
	Fields        []Field       `json:"fields"`
	UniqueIndexes []UniqueIndex `json:"uniqueIndexes"`
	PrimaryKey    PrimaryKey    `json:"primaryKey"`
}

Model describes a Prisma type model, which usually maps to a database table or collection.

func (Model) TableName

func (m Model) TableName() string

type PrimaryKey

type PrimaryKey struct {
	Name   string   `json:"name"`
	Fields []string `json:"fields"`
}

type Provider

type Provider struct {
	DriverName      string
	DriverPkg       string
	DriverSource    string
	DriverENVSource string
}

type UniqueIndex

type UniqueIndex struct {
	InternalName string   `json:"name"`
	Fields       []string `json:"fields"`
}

Jump to

Keyboard shortcuts

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