backend

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Core read operations
	GetAllPages(ctx context.Context) ([]types.PageEntity, error)
	GetPage(ctx context.Context, nameOrID any) (*types.PageEntity, error)
	GetPageBlocksTree(ctx context.Context, nameOrID any) ([]types.BlockEntity, error)
	GetBlock(ctx context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)
	GetPageLinkedReferences(ctx context.Context, nameOrID any) (json.RawMessage, error)

	// Query operations
	DatascriptQuery(ctx context.Context, query string, inputs ...any) (json.RawMessage, error)

	// Write operations
	CreatePage(ctx context.Context, name string, properties map[string]any, opts map[string]any) (*types.PageEntity, error)
	AppendBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
	PrependBlockInPage(ctx context.Context, page string, content string) (*types.BlockEntity, error)
	InsertBlock(ctx context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)
	UpdateBlock(ctx context.Context, uuid string, content string, opts ...map[string]any) error
	RemoveBlock(ctx context.Context, uuid string) error
	MoveBlock(ctx context.Context, uuid string, targetUUID string, opts map[string]any) error

	// Page management
	DeletePage(ctx context.Context, name string) error
	RenamePage(ctx context.Context, oldName, newName string) error

	// Connectivity
	Ping(ctx context.Context) error
}

Backend is the interface every knowledge graph backend must implement. The Logseq client (client.Client) satisfies this interface. Future backends (e.g. Obsidian vault) implement the same contract.

type FullTextSearcher added in v0.4.0

type FullTextSearcher interface {
	FullTextSearch(ctx context.Context, query string, limit int) ([]SearchHit, error)
}

FullTextSearcher is implemented by backends with an inverted index for efficient full-text search. When available, tools/search.go uses this instead of brute-force scanning.

type HasDataScript

type HasDataScript interface {
	HasDataScript()
}

HasDataScript is a marker interface for backends supporting DataScript queries. Logseq implements this; Obsidian does not.

type JournalResult

type JournalResult struct {
	Date   string              `json:"date"`
	Page   string              `json:"page"`
	Blocks []types.BlockEntity `json:"blocks"`
}

JournalResult holds a journal entry found by search.

type JournalSearcher

type JournalSearcher interface {
	SearchJournals(ctx context.Context, query string, from, to string) ([]JournalResult, error)
}

JournalSearcher is implemented by backends that support journal search without DataScript.

type PropertyResult

type PropertyResult struct {
	Type       string         `json:"type"` // "page" or "block"
	Name       string         `json:"name,omitempty"`
	UUID       string         `json:"uuid,omitempty"`
	Properties map[string]any `json:"properties"`
}

PropertyResult holds a page or block found by property search.

type PropertySearcher

type PropertySearcher interface {
	FindByProperty(ctx context.Context, key, value, operator string) ([]PropertyResult, error)
}

PropertySearcher is implemented by backends that support property search without DataScript.

type SearchHit added in v0.4.0

type SearchHit struct {
	PageName string `json:"page"`
	UUID     string `json:"uuid"`
	Content  string `json:"content"`
}

SearchHit is a block found by full-text search.

type TagResult

type TagResult struct {
	Page   string              `json:"page"`
	Blocks []types.BlockEntity `json:"blocks"`
}

TagResult holds a block found by tag search, grouped by page.

type TagSearcher

type TagSearcher interface {
	FindBlocksByTag(ctx context.Context, tag string, includeChildren bool) ([]TagResult, error)
}

TagSearcher is implemented by backends that support tag search without DataScript.

Jump to

Keyboard shortcuts

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