Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrDatasetNotFound = errors.New("dataset not found")
)
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct { Type AttributeType `json:"type"` Value string `json:"value,omitempty"` }
type AttributeType ¶
type AttributeType string
const ( PRIMARY_KEY AttributeType = "PRIMARY_KEY" UNIQUE AttributeType = "UNIQUE" NOT_NULL AttributeType = "NOT_NULL" DEFAULT AttributeType = "DEFAULT" MIN AttributeType = "MIN" MAX AttributeType = "MAX" MIN_LENGTH AttributeType = "MIN_LENGTH" MAX_LENGTH AttributeType = "MAX_LENGTH" )
func (*AttributeType) Clean ¶
func (a *AttributeType) Clean() error
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*AttributeType) IsValid ¶
func (a *AttributeType) IsValid() bool
func (AttributeType) String ¶
func (a AttributeType) String() string
type Column ¶
type DataType ¶
type DataType string
Data Types
func (*DataType) Clean ¶
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
type ExecutionData ¶
type ExecutionData struct { // Dataset is the DBID of the dataset that was called. // Even if a procedure in another dataset is called, this will always be the original dataset. Dataset string // Procedure is the original procedure that was called. // Even if a nested procedure is called, this will always be the original procedure. Procedure string // Mutative indicates whether the execution can mutate state. Mutative bool // Args are the arguments that were passed to the procedure. Args []any // Signer is the address of public key that signed the incoming transaction. Signer []byte // Caller is a string identifier for the signer. // It is derived from the signer's registered authenticator. // It is injected as a variable for usage in the query, under // the variable name "@caller". Caller string }
ExecutionData is contextual data that is passed to a procedure during call / execution. It is scoped to the lifetime of a single execution.
func (*ExecutionData) Clean ¶
func (e *ExecutionData) Clean() error
type Extension ¶
type Extension struct { Name string `json:"name"` Initialization []*ExtensionConfig `json:"initialization"` Alias string `json:"alias"` }
type ExtensionConfig ¶
ExtensionConfig is a key value pair that represents a configuration value for an extension
type ForeignKey ¶
type ForeignKey struct { // ChildKeys are the columns that are referencing another. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "a" is the child key ChildKeys []string `json:"child_keys"` // ParentKeys are the columns that are being referred to. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2.b" is the parent key ParentKeys []string `json:"parent_keys"` // ParentTable is the table that holds the parent columns. // For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2.b" is the parent table ParentTable string `json:"parent_table"` // Action refers to what the foreign key should do when the parent is altered. // This is NOT the same as a database action; // however sqlite's docs refer to these as actions, // so we should be consistent with that. // For example, ON DELETE CASCADE is a foreign key action Actions []*ForeignKeyAction `json:"actions"` }
func (*ForeignKey) Clean ¶
func (f *ForeignKey) Clean() error
Clean runs a set of validations and cleans the foreign key
func (*ForeignKey) Copy ¶
func (f *ForeignKey) Copy() *ForeignKey
Copy returns a copy of the foreign key
type ForeignKeyAction ¶
type ForeignKeyAction struct { // On can be either "UPDATE" or "DELETE" On ForeignKeyActionOn `json:"on"` // Do specifies what a foreign key action should do Do ForeignKeyActionDo `json:"do"` }
ForeignKeyAction is used to specify what should occur if a parent key is updated or deleted
func (*ForeignKeyAction) Clean ¶
func (f *ForeignKeyAction) Clean() error
Clean runs a set of validations and cleans the attributes in ForeignKeyAction
func (*ForeignKeyAction) Copy ¶
func (f *ForeignKeyAction) Copy() *ForeignKeyAction
Copy returns a copy of the foreign key action
type ForeignKeyActionDo ¶
type ForeignKeyActionDo string
ForeignKeyActionDo specifies what should be done when a foreign key action is triggered.
const ( // DO_NO_ACTION does nothing when a parent key is altered DO_NO_ACTION ForeignKeyActionDo = "NO ACTION" // DO_RESTRICT prevents the parent key from being altered DO_RESTRICT ForeignKeyActionDo = "RESTRICT" // DO_SET_NULL sets the child key(s) to NULL DO_SET_NULL ForeignKeyActionDo = "SET NULL" // DO_SET_DEFAULT sets the child key(s) to their default values DO_SET_DEFAULT ForeignKeyActionDo = "SET DEFAULT" // DO_CASCADE updates the child key(s) or deletes the records (depending on the action type) DO_CASCADE ForeignKeyActionDo = "CASCADE" )
func (*ForeignKeyActionDo) Clean ¶
func (f *ForeignKeyActionDo) Clean() error
Clean checks the validity or the string, and converts it to the correct case
func (*ForeignKeyActionDo) IsValid ¶
func (f *ForeignKeyActionDo) IsValid() bool
IsValid checks if the string is a valid ForeignKeyActionDo
func (ForeignKeyActionDo) String ¶
func (f ForeignKeyActionDo) String() string
String returns the ForeignKeyActionDo as a string
type ForeignKeyActionOn ¶
type ForeignKeyActionOn string
ForeignKeyActionOn specifies when a foreign key action should occur. It can be either "UPDATE" or "DELETE".
const ( // ON_UPDATE is used to specify an action should occur when a parent key is updated ON_UPDATE ForeignKeyActionOn = "UPDATE" // ON_DELETE is used to specify an action should occur when a parent key is deleted ON_DELETE ForeignKeyActionOn = "DELETE" )
func (*ForeignKeyActionOn) Clean ¶
func (f *ForeignKeyActionOn) Clean() error
Clean checks whether the string is valid, and will convert it to the correct case.
func (*ForeignKeyActionOn) IsValid ¶
func (f *ForeignKeyActionOn) IsValid() bool
IsValid checks whether or not the string is a valid ForeignKeyActionOn
func (ForeignKeyActionOn) String ¶
func (f ForeignKeyActionOn) String() string
String returns the ForeignKeyActionOn as a string
type Index ¶
type Index struct { Name string `json:"name"` Columns []string `json:"columns"` Type IndexType `json:"type"` }
type Modifier ¶
type Modifier string
const ( // View means that an action does not modify the database. ModifierView Modifier = "VIEW" // Authenticated requires that the caller is identified. ModifierAuthenticated Modifier = "AUTHENTICATED" // Owner requires that the caller is the owner of the database. ModifierOwner Modifier = "OWNER" )
type Procedure ¶
type Procedure struct { Name string `json:"name"` Annotations []string `json:"annotations,omitempty"` Args []string `json:"inputs"` Public bool `json:"public"` Modifiers []Modifier `json:"modifiers"` Statements []string `json:"statements"` }
func (*Procedure) Clean ¶
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*Procedure) EnsureContainsModifier ¶
func (*Procedure) IsMutative ¶
IsMutative returns true if the procedure is mutative.
func (*Procedure) IsOwnerOnly ¶
func (*Procedure) RequiresAuthentication ¶
type Schema ¶
type Schema struct { Name string // Owner is the identifier (generally an address in bytes or public key) of the owner of the schema Owner []byte Extensions []*Extension Tables []*Table Procedures []*Procedure }
type Table ¶
type Table struct { Name string `json:"name"` Columns []*Column `json:"columns"` Indexes []*Index `json:"indexes,omitempty"` ForeignKeys []*ForeignKey `json:"foreign_keys"` }
func (*Table) Clean ¶
Clean validates rules about the data in the struct (naming conventions, syntax, etc.).
func (*Table) GetPrimaryKey ¶
GetPrimaryKey returns the names of the column(s) that make up the primary key. If there is more than one, or no primary key, an error is returned.