sql

package
v0.0.0-...-398fdf1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 39 Imported by: 4

Documentation

Index

Constants

View Source
const (
	AssetContentsFTSCaseInsensitiveInsert = "INSERT INTO asset_contents_fts_case_insensitive (id, name, ext, path, size, updated, content) VALUES %s"
	AssetContentsPlaceholder              = "(?, ?, ?, ?, ?, ?, ?)"
)
View Source
const (
	HistoriesFTSCaseInsensitiveInsert = "INSERT INTO histories_fts_case_insensitive (id, 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

View Source
var (
	IndexIgnoreCached bool
)

Functions

func BatchRemoveAssetsQueue

func BatchRemoveAssetsQueue(hashes []string)

func BatchRemoveTreeQueue

func BatchRemoveTreeQueue(rootIDs []string)

func CacheRef

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

func ClearCache

func ClearCache()

func ClearQueue

func ClearQueue()

func CloseDatabase

func CloseDatabase()

func DefRefs

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

func DeleteAssetContentsByPathQueue

func DeleteAssetContentsByPathQueue(path string)

func DeleteBoxQueue

func DeleteBoxQueue(boxID string)

func DeleteBoxRefsQueue

func DeleteBoxRefsQueue(boxID string)

func DeleteOutdatedHistories

func DeleteOutdatedHistories(before string)

func DeleteRefsTreeQueue

func DeleteRefsTreeQueue(tree *parse.Tree)

func FlushAssetContentQueue

func FlushAssetContentQueue()

func FlushAssetContentTxJob

func FlushAssetContentTxJob()

func FlushHistoryQueue

func FlushHistoryQueue()

func FlushHistoryTxJob

func FlushHistoryTxJob()

func FlushQueue

func FlushQueue()

func FlushTxJob

func FlushTxJob()

func GetContainerText

func GetContainerText(container *ast.Node) string

func GetDuplicatedRootIDs

func GetDuplicatedRootIDs(blocksTable string) (ret []string)

func GetRefDuplicatedDefRootIDs

func GetRefDuplicatedDefRootIDs() (ret []string)

func GetRefText

func GetRefText(defBlockID string) (ret string)

func GetRootUpdated

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

func IndexAssetContentsQueue

func IndexAssetContentsQueue(assetContents []*AssetContent)

func IndexHistoriesQueue

func IndexHistoriesQueue(histories []*History)

func IndexNodeQueue

func IndexNodeQueue(id string)

func IndexTreeQueue

func IndexTreeQueue(tree *parse.Tree)

func InitAssetContentDatabase

func InitAssetContentDatabase(forceRebuild bool)

func InitDatabase

func InitDatabase(forceRebuild bool) (err error)

func InitHistoryDatabase

func InitHistoryDatabase(forceRebuild bool)

func InsertRefsTreeQueue

func InsertRefsTreeQueue(tree *parse.Tree)

func IsEmptyQueue

func IsEmptyQueue() bool

func Query

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

func QueryAssetContentNoLimit

func QueryAssetContentNoLimit(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 QueryNoLimit

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

func QueryRefCount

func QueryRefCount(defIDs []string) (ret map[string]int)

func QueryRefIDsByAnnotationID

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

func QueryRefIDsByDefID

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

func QueryRefRootBlocksByDefRootIDs

func QueryRefRootBlocksByDefRootIDs(defRootIDs []string) (ret map[string][]*Block)

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 RemoveTreePathQueue

func RemoveTreePathQueue(treeBox, treePathPrefix string)

func RemoveTreeQueue

func RemoveTreeQueue(rootID string)

func RenameSubTreeQueue

func RenameSubTreeQueue(tree *parse.Tree)

func RenameTreeQueue

func RenameTreeQueue(tree *parse.Tree)

func SetCaseSensitive

func SetCaseSensitive(b bool)

func SetIndexAssetPath

func SetIndexAssetPath(b bool)

func UpdateBlockContentQueue

func UpdateBlockContentQueue(block *Block)

func UpdateRefsTreeQueue

func UpdateRefsTreeQueue(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)

type AssetContent

type AssetContent struct {
	ID      string
	Name    string
	Ext     string
	Path    string
	Size    int64
	Updated int64
	Content string
}

func SelectAssetContentsRawStmt

func SelectAssetContentsRawStmt(stmt string, page, limit int) (ret []*AssetContent)

func SelectAssetContentsRawStmtNoParse

func SelectAssetContentsRawStmtNoParse(stmt string, limit int) (ret []*AssetContent)

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(rootIDs []string, 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 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 QueryEmptyContentEmbedBlocks

func QueryEmptyContentEmbedBlocks() (ret []*Block)

func QueryRecentUpdatedBlocks

func QueryRecentUpdatedBlocks() (ret []*Block)

func QueryRootBlockByCondition

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

func SelectBlocksRawStmt

func SelectBlocksRawStmt(stmt string, page, 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 {
	ID      string
	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(onlyDoc bool) (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) (ret []*Span)

func QueryTagSpansByKeyword

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

func QueryTagSpansByLabel

func QueryTagSpansByLabel(label string) (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