etaf-db/README.zh-CN.md

26 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# etaf-sqlite
`etaf-sqlite` 是 ETAF 的具体 SQLite 存储包,把 Emacs 内置 SQLite 能力适配到核心 `etaf-data-source` 契约。Data Controller 仍属于 `etaf`;本包只负责 schema 校验、短连接、分页查询和同步 mutation。
```elisp
(require 'etaf-sqlite)
(let* ((table (etaf-sqlite-table
'items
(list (etaf-sqlite-column :id "id" :type 'integer :primary t)
(etaf-sqlite-column :name "name" :type 'text))
:id))
(database (etaf-sqlite-database "~/items.sqlite" table))
(source (etaf-sqlite-source database)))
(etaf-sqlite-initialize database)
(etaf-data-controller source :auto-load t))
```
默认 source 仍只暴露兼容的 `:mutate` callback。需要明确的提交/回滚确定性
和只读 reconciliation 时,显式使用 `(etaf-sqlite-source database
:mutate-v2 t)` 开启增量 wrapper。
其他数据库、REST、文件和 ORM 应在各自的具体数据源包中实现同一个 source capability它们不进入 ETAF core也不创建笼统的 `etaf-adapters` 层。
在该目录运行 `make check EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs`