File tree Expand file tree Collapse file tree
docs/content/docs/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ plugins:
1919 # 可选的数据库连接选项,除了 open 选项之外的其他选项都会被传递给 DatabaseSync 的构造函数
2020 # 详见 Node.js 官方文档:https://nodejs.org/api/sqlite.html#new-databasesyncpath-options
2121 # nodeSqliteOptions:
22+ # 自动清理数据库(运行 VACUUM 命令)的相关配置
23+ autoVacuum :
24+ # 是否启用自动清理功能,默认为 true
25+ # 若为 false,则不会自动清理数据库
26+ enabled : true
27+ # 自动清理的时间间隔,单位为分钟,默认为 60
28+ intervalMinutes : 60
2229` ` `
2330
2431如果你是插件开发者,请将本插件添加到项目的 ` peerDependencies` 中,并在自己的插件中声明依赖:
@@ -240,6 +247,8 @@ ctx.kysely.schemas.register({
240247
241248完成表结构声明和迁移注册之后,` KyselyService ` 会在应用启动时自动完成迁移工作,随后就可以通过 ` ctx.kysely.db ` 来访问 Kysely 实例,并使用它来执行各种数据库操作了。下面介绍一些基本的 CRUD 操作,你可以查看 Kysely 文档的 [ Examples] ( https://kysely.dev/docs/category/examples ) 章节来了解更多用法。
242249
250+ 启用自动 vacuum 后,插件会在迁移完成后立即整理一次数据库文件,并按配置的时间间隔重复执行。默认情况下该功能处于启用状态;如果不希望插件自动执行,可以设置 ` autoVacuum.enabled ` 为 ` false ` 。也可以在需要时直接调用 ` KyselyService ` 的 ` vacuum() ` 方法。
251+
243252{ /* prettier-ignore */ }
244253<Callout >
245254如果你的插件在数据库中定义了新的结构,同时又希望外界能够对这些数据进行查询或修改,不要直接暴露这些表,而应把这些操作封装成一个新的 ` Service ` ,在其中使用 ` ctx.kysely.db ` 来访问数据库,并且使用 ` provides ` 属性和 ` ctx.provide ` 来提供这个服务。
You can’t perform that action at this time.
0 commit comments