database

package
v0.0.0-...-a4bcf30 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database manages storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contribution

type Contribution struct {
	Ref              string `json:"ref"`
	Name             string `json:"name"`
	ContributionType string `json:"type"`
	SourceURL        string
	Author           string `json:"author"`
	UploadedOn       string
	ShowcaseEnabled  bool
	Description      string `json:"description"`
	Version          string `json:"version"`
	Title            string `json:"title"`
	Homepage         string `json:"homepage"`
	Legacy           bool
}

Contribution is an activity or trigger created for Flogo

type Contributions

type Contributions []Contribution

Contributions is a slice of contribution objects

type Database

type Database struct {
	File string
	DB   *sqlx.DB
}

Database implements methods to perform operations on the database.

func MustOpenSession

func MustOpenSession(file string) *Database

MustOpenSession is like OpenSession but panics if the session cannot be created.

func OpenSession

func OpenSession(file string) (*Database, error)

OpenSession creates a new reference to an SQLite database. If the file cannot be found an exception will be returned.

func (*Database) Close

func (db *Database) Close() error

Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.

func (*Database) Exec

func (db *Database) Exec(query string) error

Exec executes a query without returning any rows. An error is returned only when the database throws an error.

func (*Database) Initialize

func (db *Database) Initialize() error

Initialize creates the new database structure. This method must be called if you're starting with a brand new database. The sourceurl (github url) is the primary key as there can be only one activity in a location.

func (*Database) InsertContribution

func (db *Database) InsertContribution(c Contribution) error

InsertContribution inserts activities and triggers into the database,

func (*Database) Query

func (db *Database) Query(opts QueryOptions) (QueryResponse, error)

Query run a query on the database and prints the result in a table.

func (*Database) UpdateContribution

func (db *Database) UpdateContribution(c Contribution) error

UpdateContribution updates the data for activities and triggers in the database,

type QueryOptions

type QueryOptions struct {
	// Writer is where the result is sent to
	Writer io.Writer

	// Query is executed on the database
	Query string

	// MergeCells enables the merge of cells with identical values
	MergeCells bool

	// RowLine enables a line on each row of the table
	RowLine bool

	// Caption sets a caption for the table
	Caption string

	// Render enables the rendering of the table output
	Render bool
}

QueryOptions represents the options you can have for a query and how the result will be rendered

type QueryResponse

type QueryResponse struct {
	Rows        [][]string
	ColumnNames []string
	Table       *tablewriter.Table
}

QueryResponse represents the response from a query

Jump to

Keyboard shortcuts

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