sql

package
v0.0.0-...-251596f Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0 Imports: 54 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 */
	BlocksPlaceholder = "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

	// blocks_fts 采用 external content 模式(content='blocks'),写入时必须显式提供 rowid,
	// 该 rowid 取自 blocks 表的隐式 rowid,否则 FTS rowid 与 blocks rowid 脱钩会导致
	// snippet/highlight 回表取错行、按 rowid 删除静默失效。首列即为 rowid。
	BlocksFTSInsert      = "" /* 193-byte string literal not displayed */
	BlocksFTSPlaceholder = "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"

	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 (

	// IsEncryptedBoxFn 由 model 层注入,用于判断 boxID 是否为加密笔记本。
	// sql 包不直接 import model(循环依赖),路由函数据此 fail-closed:
	// 加密笔记本未解锁时绝不回退全局库,避免加密笔记本索引污染全局明文库。
	IsEncryptedBoxFn func(boxID string) bool

	// IsBoxUnlockedFn 由 model 层注入,用于在读取明文缓存前确认加密笔记本仍处于解锁状态。
	IsBoxUnlockedFn func(boxID string) bool
)
View Source
var (
	IndexIgnoreCached bool
)

Functions

func BatchGetBlockAttrs

func BatchGetBlockAttrs(ids []string) (ret map[string]map[string]string)

func BatchGetBlockAttrsWitTrees

func BatchGetBlockAttrsWitTrees(ids []string, trees map[string]*parse.Tree) (ret map[string]map[string]string)

func BatchRemoveAssetsQueue

func BatchRemoveAssetsQueue(hashes []string)

func BatchRemoveTreeQueue

func BatchRemoveTreeQueue(rootIDs []string)

func CacheRef

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

func CheckAssetContentReadonlyStatement

func CheckAssetContentReadonlyStatement(stmt string) error

CheckAssetContentReadonlyStatement 在资源文件内容数据库连接上检查 SQL 是否只读。

func CheckReadonlyStatement

func CheckReadonlyStatement(stmt string) error

CheckReadonlyStatement 对整段 SQL 做 prepare(不执行),用 sqlite3_stmt_readonly 判断首条语句是否只读。 见 https://sqlite.org/c3ref/stmt_readonly.html

注意:若字符串里在语法上还有第二条及以后的语句,本函数只针对「首条」对应的 stmt 做判断, 不会拒绝多语句。与 CheckSingleStatement 组合即可得到「单条 + 只读」策略。 仅允许 SELECT 和 WITH 查询,避免 SQLite 将 ATTACH、DETACH 和事务控制语句标记为只读后放行。

func CheckReadonlyStatementInBox

func CheckReadonlyStatementInBox(stmt, boxID string) error

CheckReadonlyStatementInBox 在指定笔记本对应的数据库连接上检查 SQL 是否只读。

func CheckSingleStatement

func CheckSingleStatement(stmt string) error

func ClearCache

func ClearCache()

func ClearQueue

func ClearQueue()

func CloseDatabase

func CloseDatabase()

func CloseEncryptedDB

func CloseEncryptedDB(boxID string)

CloseEncryptedDB 仅关闭加密笔记本的 db 连接(不删文件)。UnlockBox 创建失败回滚时调用。 关闭/锁定加密笔记本请用 RemoveEncryptedDBFile(关连接 + 删文件)。

func DefRefs

func DefRefs(condition string, limit int) (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 int64)

func DeleteRefsTreeQueue

func DeleteRefsTreeQueue(tree *parse.Tree)

func Exec

func Exec(stmt string, args ...any) error

func ExistRefByDefIDs

func ExistRefByDefIDs(defIDs, defRootIDs, excludeBlockIDs, excludeRootIDs []string) (ret bool, err error)

ExistRefByDefIDs 检查全局库及所有已打开加密库中来自删除集合外部的引用。

func ExistRefByDefIDsInBox

func ExistRefByDefIDsInBox(defIDs, defRootIDs, excludeBlockIDs, excludeRootIDs []string, boxID string) (ret bool, err error)

ExistRefByDefIDsInBox 检查指定笔记本索引中是否存在来自删除集合外部的引用。

func FillAttributeViewNilValue

func FillAttributeViewNilValue(value *av.Value, typ av.KeyType)

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 GetBlockAttrs

func GetBlockAttrs(id string) (ret map[string]string)

func GetContainerText

func GetContainerText(container *ast.Node) string

func GetDuplicatedRootIDs

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

func GetEncryptedBoxIDs

func GetEncryptedBoxIDs() (ret []string)

GetEncryptedBoxIDs 返回所有已打开的加密 content db 对应的 boxID。

func GetEncryptedDB

func GetEncryptedDB(boxID string) *sql.DB

GetEncryptedDB 返回加密笔记本的 db 句柄;未打开返回 nil。

func GetFurtherCollections

func GetFurtherCollections(attrView *av.AttributeView,
	cachedAttrViews map[string]*av.AttributeView) map[string]*av.RollupRenderContext

func GetRefDuplicatedDefRootIDs

func GetRefDuplicatedDefRootIDs() (ret []string)

func GetRefText

func GetRefText(defBlockID string) (ret string)

func GetRefTextInBox

func GetRefTextInBox(defBlockID, boxID string) (ret string)

GetRefTextInBox 按 defBlockID 在指定 box 的 db 里查引用文本。

func GetRootUpdated

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

func GetTemplateKeyRelevantKeys

func GetTemplateKeyRelevantKeys(attrView *av.AttributeView, templateKey *av.Key) (ret []*av.Key)

func GetTemplateKeysByResolutionOrder

func GetTemplateKeysByResolutionOrder(attrView *av.AttributeView) (ret []*av.Key, resolved bool)

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)

func InitHistoryDatabase

func InitHistoryDatabase(forceRebuild bool)

func MoveTreeQueue

func MoveTreeQueue(tree *parse.Tree)

func NodeStaticContent

func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath, fullAttrView bool) string

func OpenEncryptedDB

func OpenEncryptedDB(boxID string, dek []byte) (err error)

OpenEncryptedDB 打开加密笔记本的独立 SQLCipher db 并注册到 encryptedDBs。 dek 是该 box 的 32 字节数据密钥;先用 HKDF 派生 content 子密钥(用途分离),DSN 用 raw key 格式 x'<hex>'。 首次打开会建表(幂等 IF NOT EXISTS)。UnlockBox 时调用。

func Query

func Query(stmt string, limit int) (ret []map[string]any, err error)

func QueryAssetContentNoLimit

func QueryAssetContentNoLimit(stmt string) (ret []map[string]any, err error)

func QueryAssetContentNoLimitArgs

func QueryAssetContentNoLimitArgs(stmt string, args ...any) (ret []map[string]any, err error)

QueryAssetContentNoLimitArgs 使用绑定参数查询资源文件内容数据库。

func QueryBlockAliases

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

func QueryBlockAliasesInBox

func QueryBlockAliasesInBox(rootID, boxID string) (ret []string)

QueryBlockAliasesInBox 按 rootID 在指定 box 的 db 里查块别名(按逗号拆分去重)。

func QueryBlockDefIDsByRefText

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

func QueryBlockDefIDsByRefTextInBox

func QueryBlockDefIDsByRefTextInBox(refText, boxID string) (ret []string)

func QueryBlockNamesByRootID

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

func QueryBlockNamesByRootIDInBox

func QueryBlockNamesByRootIDInBox(rootID, boxID string) (ret []string)

QueryBlockNamesByRootIDInBox 按 rootID 在指定 box 的 db 里查块命名。

func QueryBookmarkLabels

func QueryBookmarkLabels() (ret []string)

func QueryBoundBlockAVIDs

func QueryBoundBlockAVIDs(blockIDs, rootIDs []string) (ret map[string][]string, err error)

QueryBoundBlockAVIDs 查询全局库及所有已打开加密库中删除集合内的数据库绑定块。

func QueryBoundBlockAVIDsInBox

func QueryBoundBlockAVIDsInBox(blockIDs, rootIDs []string, boxID string) (ret map[string][]string, err error)

QueryBoundBlockAVIDsInBox 查询删除集合中绑定块所属的属性视图。

func QueryChildDefIDsByRootDefID

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

func QueryChildRefDefIDsByRootDefID

func QueryChildRefDefIDsByRootDefID(rootDefID string) (ret map[string][]string)

func QueryChildRefDefIDsByRootDefIDInBox

func QueryChildRefDefIDsByRootDefIDInBox(rootDefID, boxID string) (ret map[string][]string)

QueryChildRefDefIDsByRootDefIDInBox 按 rootDefID 查子引用定义,按 boxID 路由。

func QueryHistory

func QueryHistory(stmt string) (ret []map[string]any, err error)

func QueryNoLimit

func QueryNoLimit(stmt string) (ret []map[string]any, err error)

func QueryNoLimitArgs

func QueryNoLimitArgs(stmt string, args ...any) (ret []map[string]any, err error)

QueryNoLimitArgs 与 QueryNoLimit 一致,但支持参数化查询(stmt 中用 ? 占位,args 顺序填入)。 用于 embedding 索引器按 fail_count/last_tried 调度时的带参 SELECT。

func QueryNoLimitArgsInBox

func QueryNoLimitArgsInBox(stmt, boxID string, args ...any) (ret []map[string]any, err error)

QueryNoLimitArgsInBox 与 QueryNoLimitInBox 一致,但支持参数化查询。

func QueryNoLimitInBox

func QueryNoLimitInBox(stmt, boxID string) (ret []map[string]any, err error)

QueryNoLimitInBox 在指定 box 的 db 里执行无 limit 的原始查询(返回 map 行)。

func QueryNoLimitInBoxContext

func QueryNoLimitInBoxContext(ctx context.Context, stmt, boxID string) (ret []map[string]any, err error)

func QueryRefCount

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

func QueryRefCountInBox

func QueryRefCountInBox(defIDs []string, boxID string) (ret map[string]int)

QueryRefCountInBox 按 defBlockIDs 在指定 box 的 db 里查引用计数。

func QueryRefIDsByAnnotationID

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

func QueryRefIDsByAnnotationIDInBox

func QueryRefIDsByAnnotationIDInBox(annotationID, boxID string) (refIDs []string)

func QueryRefIDsByDefID

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

func QueryRefIDsByDefIDInBox

func QueryRefIDsByDefIDInBox(defID string, containChildren bool, boxID string) (refIDs []string)

QueryRefIDsByDefIDInBox 按 defID 查引用 ID 列表,按 boxID 路由。

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 QueryRootChildrenRefCountInBox

func QueryRootChildrenRefCountInBox(defRootID, boxID string) (ret map[string]int)

QueryRootChildrenRefCountInBox 按 defRootID 在指定 box 的 db 里查询根文档下各块的引用计数。

func QueryVirtualRefKeywords

func QueryVirtualRefKeywords(name, alias, anchor, doc bool, searchIgnoreLines, refSearchIgnoreLines []string, boxIDs ...string) (ret []string)

func RebuildFTSIndex

func RebuildFTSIndex() (err error)

func RemoveAllEncryptedDBFiles

func RemoveAllEncryptedDBFiles()

RemoveAllEncryptedDBFiles 关闭所有已打开的加密 content db 连接并删除其文件(含 WAL/SHM)。 进程退出(CloseDatabase)时调用,避免重启后残留旧索引数据导致下次解锁叠加重复行。

func RemoveEncryptedDBFile

func RemoveEncryptedDBFile(boxID string)

RemoveEncryptedDBFile 关闭连接并删除加密 db 文件(含 WAL/SHM)。删除笔记本、关闭加密笔记本时调用。

func RemoveTreePathQueue

func RemoveTreePathQueue(treeBox, treePathPrefix string)

func RemoveTreeQueue

func RemoveTreeQueue(boxID, rootID string)

func RenameTreeQueue

func RenameTreeQueue(tree *parse.Tree)

func RenderAttributeViewGallery

func RenderAttributeViewGallery(attrView *av.AttributeView, view *av.View, query string, depth *int, cachedAttrViews map[string]*av.AttributeView, ignoreRows bool) (ret *av.Gallery)

func RenderAttributeViewKanban

func RenderAttributeViewKanban(attrView *av.AttributeView, view *av.View, query string, depth *int, cachedAttrViews map[string]*av.AttributeView, ignoreRows bool) (ret *av.Kanban)

func RenderAttributeViewTable

func RenderAttributeViewTable(attrView *av.AttributeView, view *av.View, query string, depth *int, cachedAttrViews map[string]*av.AttributeView, ignoreRows bool) (ret *av.Table)

func RenderGroupView

func RenderGroupView(attrView *av.AttributeView, view, groupView *av.View, query string) (ret av.Viewable)

func RenderView

func RenderView(attrView *av.AttributeView, view *av.View, query string, ignoreRows bool) (ret av.Viewable)

func SQLTemplateFuncs

func SQLTemplateFuncs(templateFuncMap *template.FuncMap, boxIDs ...string)

func SetCaseSensitive

func SetCaseSensitive(b bool)

func SetHanSensitive

func SetHanSensitive(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 Vacuum

func Vacuum()

func WaitFlushTx

func WaitFlushTx()

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)

func SelectAssetContentsRawStmtNoParseArgs

func SelectAssetContentsRawStmtNoParseArgs(stmt string, args []any, limit int) (ret []*AssetContent)

SelectAssetContentsRawStmtNoParseArgs 使用绑定参数查询资源文件内容,并保留调用方构造的 SQL。

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, limit int) (ret []*Block)

func GetAllRootBlocks

func GetAllRootBlocks() (ret []*Block)

func GetBlock

func GetBlock(id string) (ret *Block)

func GetBlockInBox

func GetBlockInBox(id, boxID string) (ret *Block)

GetBlockInBox 按 id 在指定 box 的 db 里查 block。boxID 为空则查全局 db。

func GetBlocks

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

func GetBlocksInBox

func GetBlocksInBox(ids []string, boxID string) (ret []*Block)

GetBlocksInBox 按 ids 在指定 box 的 db 里批量查 block。

func GetChildBlocks

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

func GetChildBlocksInBox

func GetChildBlocksInBox(parentID, condition string, limit int, boxID string) (ret []*Block)

GetChildBlocksInBox 按 parentID 在指定 box 的 db 里查所有子块。

func QueryBookmarkBlocks

func QueryBookmarkBlocks() (ret []*Block)

func QueryDefRootBlocksByRefRootID

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

func QueryEmptyContentEmbedBlocks

func QueryEmptyContentEmbedBlocks() (ret []*Block)

func QueryEmptyContentEmbedBlocksInBox

func QueryEmptyContentEmbedBlocksInBox(boxID string) (ret []*Block)

func QueryRootBlockByCondition

func QueryRootBlockByCondition(condition, exactKeyword string, limit int, args ...any) (ret []*Block)

func QueryRootBlockByConditionInBox

func QueryRootBlockByConditionInBox(condition, exactKeyword string, limit int, boxID string, args ...any) (ret []*Block)

func SelectBlocksRawStmt

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

func SelectBlocksRawStmtArgs

func SelectBlocksRawStmtArgs(stmt string, args []any, limit int) (ret []*Block)

SelectBlocksRawStmtArgs 与 selectBlocksRawStmt 行为一致,但通过绑定参数执行, 绕开 sqlparser 解析(vitess 会把 "?" 改写为 ":vN" 导致占位失效),用于含用户可控参数的搜索语句。

func SelectBlocksRawStmtArgsInBox

func SelectBlocksRawStmtArgsInBox(stmt string, args []any, limit int, boxID string) (ret []*Block)

SelectBlocksRawStmtArgsInBox 在指定 box 的 db 里执行参数化原始 SQL 查询 blocks。 与 SelectBlocksRawStmtArgs 对应,绕开 sqlparser 对 "?" 占位的改写。

func SelectBlocksRawStmtInBox

func SelectBlocksRawStmtInBox(stmt string, page, limit int, boxID string) (ret []*Block)

SelectBlocksRawStmtInBox 在指定 box 的 db 里执行原始 SQL 查询 blocks。

func SelectBlocksRawStmtInBoxContext

func SelectBlocksRawStmtInBoxContext(ctx context.Context, stmt string, page, limit int, boxID string) (ret []*Block, err error)

func SelectBlocksRawStmtNoParse

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

func SelectBlocksRawStmtNoParseInBox

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

SelectBlocksRawStmtNoParseInBox 与 SelectBlocksRawStmtNoParse 一致,但按 boxID 路由。

func SelectBlocksRegex

func SelectBlocksRegex(stmt string, exp *regexp.Regexp, name, alias, memo, ial bool, page, pageSize int) (ret []*Block)

func SelectBlocksRegexArgs

func SelectBlocksRegexArgs(stmt string, exp *regexp.Regexp, name, alias, memo, ial bool, page, pageSize int, args ...any) (ret []*Block)

SelectBlocksRegexArgs 与 SelectBlocksRegex 行为一致,但通过绑定参数执行, 绕开 sqlparser 解析(vitess 会把 "?" 改写为 ":vN" 导致占位失效),用于含用户可控参数的正则搜索。

func SelectBlocksRegexArgsInBox

func SelectBlocksRegexArgsInBox(stmt string, exp *regexp.Regexp, name, alias, memo, ial bool, page, pageSize int, boxID string, args ...any) (ret []*Block)

SelectBlocksRegexArgsInBox 与 SelectBlocksRegexInBox 一致,但通过绑定参数执行。

func SelectBlocksRegexInBox

func SelectBlocksRegexInBox(stmt string, exp *regexp.Regexp, name, alias, memo, ial bool, page, pageSize int, boxID string) (ret []*Block)

SelectBlocksRegexInBox 在指定 box 的 db 里执行正则匹配查询 blocks(无占位参数版)。

func ToBlocks

func ToBlocks(result []map[string]any) (ret []*Block)

func (*Block) IsContainerBlock

func (block *Block) IsContainerBlock() bool

type BookmarkLabelBlock

type BookmarkLabelBlock struct {
	Label string
	Box   string
	Path  string
}

func QueryBookmarkLabelBlocks

func QueryBookmarkLabelBlocks() (ret []*BookmarkLabelBlock)

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 GetRefsCacheByDefIDInBox

func GetRefsCacheByDefIDInBox(defID, boxID string) (ret []*Ref)

func QueryRefsByDefID

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

func QueryRefsByDefIDInBox

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

QueryRefsByDefIDInBox 按 defBlockID 在指定 box 的 db 里查引用列表。 containChildren 为 true 时递归查询定义块及其所有子块,与 QueryRefsByDefID 保持一致。

func QueryRefsByDefIDRefID

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

func QueryRefsByDefIDRefIDInBox

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

QueryRefsByDefIDRefIDInBox 按 defBlockID+refBlockID 在指定 box 的 db 里查引用。

func QueryRefsRecent

func QueryRefsRecent(onlyDoc bool, typeFilter string, ignoreLines []string) (ret []*Ref)

func QueryRefsRecentInBox

func QueryRefsRecentInBox(onlyDoc bool, typeFilter string, ignoreLines, recentDefBlockIDs []string, boxID string) (ret []*Ref)

QueryRefsRecentInBox 按 boxID 路由查最近引用,用于加密笔记本内的块引搜索。

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)

func SelectSpansRawStmtInBox

func SelectSpansRawStmtInBox(stmt string, limit int, boxID string) (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