Back to godoc.org
github.com/documize/community/core/database

package database

v3.2.0+incompatible
Latest Go to latest
Published: Aug 29, 2019 | License: AGPL-3.0 | Module: github.com/documize/community

Index

func Check

func Check(runtime *env.Runtime) bool

Check that the database is configured correctly and that all the required tables exist. It must be the first function called in this package.

func CurrentVersion

func CurrentVersion(runtime *env.Runtime) (version int, err error)

CurrentVersion returns number that represents the current database version number. For example 23 represents the 23rd iteration of the database.

func InstallUpgrade

func InstallUpgrade(runtime *env.Runtime, existingDB bool) (err error)

InstallUpgrade creates new database or upgrades existing database.

func RebindParams

func RebindParams(sql string, s env.StoreType) string

RebindParams changes MySQL query parameter placeholder from "?" to correct value for given database provider.

MySQL uses ?, ?, ? (default for all Documize queries) PostgreSQL uses $1, $2, $3 MS SQL Server uses @p1, @p2, @p3

func RebindPostgreSQL

func RebindPostgreSQL(sql string) string

RebindPostgreSQL is a helper method on top of RebindParams.

type Handler

type Handler struct {
	Runtime *env.Runtime
	Store   *store.Store
}

Handler contains the runtime information such as logging and database.

func (*Handler) Setup

func (h *Handler) Setup(w http.ResponseWriter, r *http.Request)

Setup the tables in a blank database

type Script

type Script struct {
	Version int
	Script  []byte
}

Script holds SQL script and it's associated version number.

func SpecificScripts

func SpecificScripts(runtime *env.Runtime, all Scripts) (s []Script)

SpecificScripts returns SQL scripts for current databasse provider.

type Scripts

type Scripts struct {
	MySQL      []Script
	PostgreSQL []Script
	SQLServer  []Script
}

Scripts holds all .SQL files for all supported database providers.

func LoadScripts

func LoadScripts() (s Scripts, err error)

LoadScripts returns .SQL scripts for supported database providers.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier