跳到主要内容

buildCreateFtsTableSql()

function buildCreateFtsTableSql(table, fields): string;

Defined in: packages/rxdb-adapter-sqlite-core/src/fts5/create-fts-table.ts:18

生成单个 collection 的 FTS5 外部内容虚拟表 DDL。

表名约定:_fts_<table>;tokenizer 固定为 unicode61 remove_diacritics 2。 使用 SQLite 隐式 rowid 作为 external content 关联键(content_rowid 默认即 rowid): 业务主键既可能是 INTEGER PRIMARY KEY(rowid 别名)也可能是 TEXT/UUID,无论哪种 类型 SQLite 都会维护稳定的隐式 rowid,trigger 与查询一致使用 rowid 关联即可。 业务主键值通过 JOIN sourceTable src ON src.rowid = fts.rowid 在查询阶段还原。

Parameters

ParameterTypeDescription
tablestring业务表名(不带 _fts_ 前缀)
fieldsreadonly FtsField[]参与 FTS5 索引的字段(顺序保留,作为 FTS5 列声明顺序)

Returns

string

单条 CREATE VIRTUAL TABLE IF NOT EXISTS SQL 语句