sql

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HistoriesFTSCaseInsensitiveInsert = "INSERT INTO histories_fts_case_insensitive (type, op, title, content, path, created) VALUES %s"
	HistoriesPlaceholder              = "(?, ?, ?, ?, ?, ?)"
)
View Source
const (
	BlocksInsert                   = "" /* 182-byte string literal not displayed */
	BlocksFTSInsert                = "" /* 186-byte string literal not displayed */
	BlocksFTSCaseInsensitiveInsert = "" /* 203-byte string literal not displayed */
	BlocksPlaceholder              = "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

	SpansInsert      = "INSERT INTO spans (id, block_id, root_id, box, path, content, markdown, type, ial) VALUES %s"
	SpansPlaceholder = "(?, ?, ?, ?, ?, ?, ?, ?, ?)"

	AssetsPlaceholder             = "(?, ?, ?, ?, ?, ?, ?, ?, ?)"
	AttributesPlaceholder         = "(?, ?, ?, ?, ?, ?, ?, ?)"
	RefsPlaceholder               = "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
	FileAnnotationRefsPlaceholder = "(?, ?, ?, ?, ?, ?, ?, ?, ?)"
)

Variables

This section is empty.

Functions

func AutoFlushTreeQueue

func AutoFlushTreeQueue()

func BeginHistoryTx

func BeginHistoryTx() (tx *sql.Tx, err error)

func BeginTx

func BeginTx() (tx *sql.Tx, err error)

func CacheRef

func CacheRef(tree *parse.Tree, refNode *ast.Node)

func ClearBlockCache

func ClearBlockCache()

func ClearBoxHash

func ClearBoxHash(tx *sql.Tx)

func ClearQueue

func ClearQueue()

func ClearVirtualRefKeywords

func ClearVirtualRefKeywords()

func CloseDatabase

func CloseDatabase()

func CommitTx

func CommitTx(tx *sql.Tx) (err error)

func DefRefs

func DefRefs(condition string) (ret []map[*Block]*Block)

func DeleteAssetsByHashes

func DeleteAssetsByHashes(hashes []string)

func DeleteBlockByIDs

func DeleteBlockByIDs(tx *sql.Tx, ids []string) (err error)

func DeleteByBoxTx

func DeleteByBoxTx(tx *sql.Tx, box string) (err error)

func DeleteByRootID

func DeleteByRootID(tx *sql.Tx, rootID string) (err error)

func DeleteHistoriesByPathPrefix

func DeleteHistoriesByPathPrefix(tx *sql.Tx, pathPrefix string) (err error)

func DeleteRefsByBoxTx

func DeleteRefsByBoxTx(tx *sql.Tx, box string) (err error)

func DisableCache

func DisableCache()

func EnableCache

func EnableCache()

func GetBoxHash

func GetBoxHash(box string) string

func GetContainerText

func GetContainerText(container *ast.Node) string

func GetDuplicatedRootIDs

func GetDuplicatedRootIDs() (ret []string)

func GetRefText

func GetRefText(defBlockID string) (ret string)

func GetRootUpdated

func GetRootUpdated() (ret map[string]string, err error)

func IndexMode

func IndexMode()

func InitDatabase

func InitDatabase(forceRebuild bool) (err error)

func InitHistoryDatabase

func InitHistoryDatabase(forceRebuild bool)

func InsertBlock

func InsertBlock(tx *sql.Tx, block *Block, context map[string]interface{}) (err error)

func InsertBlocksSpans

func InsertBlocksSpans(tx *sql.Tx, tree *parse.Tree, context map[string]interface{}) (err error)

func InsertHistories

func InsertHistories(tx *sql.Tx, histories []*History) (err error)

func InsertRefs

func InsertRefs(tx *sql.Tx, tree *parse.Tree)

func IsBlockFolded

func IsBlockFolded(id string) (ret bool)

func IsEmptyQueue

func IsEmptyQueue() bool

func NormalMode

func NormalMode()

func PutBoxHash

func PutBoxHash(tx *sql.Tx, box, hash string)

func Query

func Query(stmt string) (ret []map[string]interface{}, err error)

func QueryBlockAliases

func QueryBlockAliases(rootID string) (ret []string)

func QueryBlockDefIDsByRefText

func QueryBlockDefIDsByRefText(refText string, excludeIDs []string) (ret []string)

func QueryBlockNamesByRootID

func QueryBlockNamesByRootID(rootID string) (ret []string)

func QueryBookmarkLabels

func QueryBookmarkLabels() (ret []string)

func QueryChildDefIDsByRootDefID

func QueryChildDefIDsByRootDefID(rootDefID string) (ret []string)

func QueryHistory

func QueryHistory(stmt string) (ret []map[string]interface{}, err error)

func QueryRefIDsByAnnotationID

func QueryRefIDsByAnnotationID(annotationID string) (refIDs, refTexts []string)

func QueryRefIDsByDefID

func QueryRefIDsByDefID(defID string, containChildren bool) (refIDs, refTexts []string)

func QueryRootBlockRefCount

func QueryRootBlockRefCount() (ret map[string]int)

func QueryRootChildrenRefCount

func QueryRootChildrenRefCount(defRootID string) (ret map[string]int)

func QueryVirtualRefKeywords

func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string)

func RemoveBoxHash

func RemoveBoxHash(tx *sql.Tx, box string)

func RemoveTreePathQueue

func RemoveTreePathQueue(treeBox, treePathPrefix string)

func RemoveTreeQueue

func RemoveTreeQueue(box, rootID string)

func RenameTreeQueue

func RenameTreeQueue(tree *parse.Tree, oldHPath string)

func RollbackTx

func RollbackTx(tx *sql.Tx)

func SetCaseSensitive

func SetCaseSensitive(b bool)

func UpsertRefs

func UpsertRefs(tx *sql.Tx, tree *parse.Tree)

func UpsertTreeQueue

func UpsertTreeQueue(tree *parse.Tree)

func WaitForWritingDatabase

func WaitForWritingDatabase()

Types

type Asset

type Asset struct {
	ID      string
	BlockID string
	RootID  string
	Box     string
	DocPath string
	Path    string
	Name    string
	Title   string
	Hash    string
}

func QueryAssetByHash

func QueryAssetByHash(hash string) (ret *Asset)

func QueryRootBlockAssets

func QueryRootBlockAssets(rootID string) (ret []*Asset)

type Attribute

type Attribute struct {
	ID      string
	Name    string
	Value   string
	Type    string
	BlockID string
	RootID  string
	Box     string
	Path    string
}

type Block

type Block struct {
	ID       string
	ParentID string
	RootID   string
	Hash     string
	Box      string
	Path     string
	HPath    string
	Name     string
	Alias    string
	Memo     string
	Tag      string
	Content  string
	FContent string
	Markdown string
	Length   int
	Type     string
	SubType  string
	IAL      string
	Sort     int
	Created  string
	Updated  string
}

func BuildBlockFromNode

func BuildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block)

func GetAllChildBlocks

func GetAllChildBlocks(rootID, condition string) (ret []*Block)

func GetAllRootBlocks

func GetAllRootBlocks() (ret []*Block)

func GetBlock

func GetBlock(id string) (ret *Block)

func GetBlocks

func GetBlocks(ids []string) (ret []*Block)

func GetChildBlocks

func GetChildBlocks(parentID, condition string) (ret []*Block)

func GetRefExistedBlocks

func GetRefExistedBlocks() (ret []*Block)

func QueryBlockByNameOrAlias

func QueryBlockByNameOrAlias(rootID, text string) (ret *Block)

func QueryBookmarkBlocks

func QueryBookmarkBlocks() (ret []*Block)

func QueryBookmarkBlocksByKeyword

func QueryBookmarkBlocksByKeyword(bookmark string) (ret []*Block)

func QueryDefRootBlocksByRefRootID

func QueryDefRootBlocksByRefRootID(refRootID string) (ret []*Block)

func QueryRecentUpdatedBlocks

func QueryRecentUpdatedBlocks() (ret []*Block)

func QueryRefRootBlocksByDefRootID

func QueryRefRootBlocksByDefRootID(defRootID string) (ret []*Block)

func QueryRootBlockByCondition

func QueryRootBlockByCondition(condition string) (ret []*Block)

func SelectBlocksRawStmt

func SelectBlocksRawStmt(stmt string, limit int) (ret []*Block)

func SelectBlocksRawStmtNoParse

func SelectBlocksRawStmtNoParse(stmt string, limit int) (ret []*Block)

func (*Block) IsContainerBlock

func (block *Block) IsContainerBlock() bool

type FileAnnotationRef

type FileAnnotationRef struct {
	ID           string
	FilePath     string
	AnnotationID string
	BlockID      string
	RootID       string
	Box          string
	Path         string
	Content      string
	Type         string
}

type History

type History struct {
	Type    int
	Op      string
	Title   string
	Content string
	Created string
	Path    string
}

func SelectHistoriesRawStmt

func SelectHistoriesRawStmt(stmt string) (ret []*History)

type Ref

type Ref struct {
	ID               string
	DefBlockID       string
	DefBlockParentID string
	DefBlockRootID   string
	DefBlockPath     string
	BlockID          string
	RootID           string
	Box              string
	Path             string
	Content          string
	Markdown         string
	Type             string
}

func GetRefsCacheByDefID

func GetRefsCacheByDefID(defID string) (ret []*Ref)

func QueryRefsByDefID

func QueryRefsByDefID(defBlockID string, containChildren bool) (ret []*Ref)

func QueryRefsByDefIDRefID

func QueryRefsByDefIDRefID(defBlockID, refBlockID string) (ret []*Ref)

func QueryRefsRecent

func QueryRefsRecent() (ret []*Ref)

type Span

type Span struct {
	ID       string
	BlockID  string
	RootID   string
	Box      string
	Path     string
	Content  string
	Markdown string
	Type     string
	IAL      string
}

func QueryTagSpans

func QueryTagSpans(p string, limit int) (ret []*Span)

func QueryTagSpansByKeyword

func QueryTagSpansByKeyword(keyword string, limit int) (ret []*Span)

func SelectSpansRawStmt

func SelectSpansRawStmt(stmt string, limit int) (ret []*Span)

type Stat

type Stat struct {
	Key string `json:"key"`
	Val string `json:"value"`
}

Jump to

Keyboard shortcuts

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