TiddlyWiki / TiddlyWiki/MultiWikiServer

Filter to sql

Open
#13 11 comments 0 reactions 3 assignees View on GitHub

@Arlen22 is already working on this.

Since Mar 21, 2025.

Dominant language
TypeScript
Stars
60
Forks
16
PR merge metrics
No merged PRs in 30d

Description

I'm going to add a src/filter-ast-util-to-sql , similar to https://github.com/syntax-tree/mdast-util-from-markdown , @Arlen22 is that the right place?

For Filter AST, I'll reuse AST intimated in https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/editions/test/tiddlers/tests/test-filters.js

  1. Add Filter AST to https://github.com/tiddly-gittly/TW5-Typed
  2. Try compile some "selection constructors" described in https://tiddlywiki.com/#Selection%20Constructors to SQL
  3. Modify core to allow hook into compileFilter, when creating operationSubFunction and getting filterOperators[operator.operator] , it will ask for th-getOperationSubFunction and th-getFilterOperators, so we can provide SQL execution based function to it.
    1. if a filter run can fully transform to SQL, we return function at th-getOperationSubFunction, if some filter operator is JS only, cause only some part of filter run can run as SQL, we return function at th-getFilterOperators
    2. Get transforms by module-type: sqlfilteroperator at runtime in the future, but now simply write them as an static JS Map.
  4. For backlink that has indexer, we could use a sqlite table to store indexer, and overwrite existing JS based indexer by addIndexer (need to modify core to allow overwrite)
    1. this is the slowest part of JS filter, we will have most of performance boost here.
    2. we presist the indexer tables, and only update necessary rows when that tiddler changes
    3. filesystem-adaptor should check tid file hashs, and report percise change to MWS, instead of loading all files and rebuild every cache from ground up every time

This involves some core changes, @Jermolene what's your suggesstion?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.