ext/web W6: schema migrate and SQLite FTS5 search
Add db.migrate with _marqdo_migrations, db.fts/search (bm25), and gold covering published filters plus a comments table convention. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a900fd550f
commit
e3b0314382
8 files changed
+498
-5
No files matched your search
@@ -242,6 +242,35 @@ Count rows matching a `where` filter (same syntax as `select`). Returns a number
|
||||
*r = > web_db_count url=`url` table=`table` where=`where` txn=`txn`*
|
||||
**r[^count]**
|
||||
|
||||
## migrate
|
||||
+ `steps`
|
||||
|
||||
Apply versioned SQL migrations. `steps` is a `|version|sql|` / `|版本|SQL|` table. Applied versions are recorded in `_marqdo_migrations`. Re-running is a no-op for already-applied versions. SQLite only.
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_migrate url=`url` steps=`steps`**
|
||||
|
||||
## fts
|
||||
+ `table`
|
||||
+ `columns`
|
||||
+ `name`=None
|
||||
|
||||
Create an FTS5 index on `table` for the listed content columns (CSV string or list). Default FTS name is `{table}_fts`. Keeps the index in sync via triggers. Requires integer `id` PK. SQLite only.
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_fts_create url=`url` table=`table` columns=`columns` name=`name`**
|
||||
|
||||
## search
|
||||
+ `table`
|
||||
+ `q`
|
||||
+ `limit`=20
|
||||
+ `name`=None
|
||||
|
||||
Full-text search (`MATCH`) against the FTS5 index from `fts`. Returns `{ rows, count }` with a `rank` column (bm25). SQLite only.
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_search url=`url` table=`table` q=`q` limit=`limit` name=`name`**
|
||||
|
||||
## 事务
|
||||
|
||||
Begin a transaction: borrows the pooled connection exclusively and returns a
|
||||
|
||||
@@ -229,6 +229,35 @@ SEO / OpenGraph 元数据表(`|键|值|`)。如 `title`、`description`、`c
|
||||
*r = > web_db_count url=`url` table=`表` where=`条件` txn=`事务`*
|
||||
**r[^count]**
|
||||
|
||||
## 迁移
|
||||
+ `步骤`
|
||||
|
||||
按版本执行 SQL 迁移。`步骤` 为 `|版本|SQL|` 表;已应用版本记入 `_marqdo_migrations`。重复执行对已应用版本是空操作。仅 SQLite。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_migrate url=`url` steps=`步骤`**
|
||||
|
||||
## 全文
|
||||
+ `表`
|
||||
+ `列`
|
||||
+ `名`=None
|
||||
|
||||
为 `表` 的内容列创建 FTS5 索引(CSV 或列表)。默认索引名 `{表}_fts`,用触发器保持同步。需要整数 `id` 主键。仅 SQLite。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_fts_create url=`url` table=`表` columns=`列` name=`名`**
|
||||
|
||||
## 搜索
|
||||
+ `表`
|
||||
+ `关键词`
|
||||
+ `上限`=20
|
||||
+ `名`=None
|
||||
|
||||
对 `全文` 建立的索引做 `MATCH` 检索。返回 `{ rows, count }`,含 `rank`(bm25)。仅 SQLite。
|
||||
|
||||
*url = self[^url]*
|
||||
**> web_db_search url=`url` table=`表` q=`关键词` limit=`上限` name=`名`**
|
||||
|
||||
## 事务
|
||||
|
||||
开启一个事务:从连接池独占借用连接,返回 `事务` 句柄。在事务内写入,然后 `提交` 或 `回滚`。所有语句在同一连接上执行,整批写入是原子的。
|
||||
|
||||
Reference in new issue
Block a user