Getting Started
复制一个包含安装步骤和此插件的完整 Markdown 指南的设置提示。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-data-storage-sqlite`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/data-storage-sqlite/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
安装
标题为“安装”您可以使用我们的 AI 助手设置来安装插件。将 Capgo 技能添加到您的 AI 工具中,使用以下命令:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins然后使用以下提示:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-data-storage-sqlite` plugin in my project.如果您prefer手动设置,安装插件并运行以下命令并遵循以下平台特定的说明:
bun add @capgo/capacitor-data-storage-sqlitebunx cap sync导入
导入import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';API概述
API概述openStore
打开商店复制到剪贴板
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({} as capOpenStorageOptions);closeStore
关闭商店关闭商店
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.closeStore({} as capStorageOptions);isStoreOpen
标题:“isStoreOpen”检查商店是否已打开
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.isStoreOpen({} as capStorageOptions);isStoreExists
标题:“isStoreExists”检查商店是否存在
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.isStoreExists({} as capStorageOptions);deleteStore
标题:“deleteStore”删除商店
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteStore({} as capOpenStorageOptions);setTable
标题:“setTable”设置或添加一个表格到一个已有的商店
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.setTable({} as capTableStorageOptions);set
标题: “set”存储一个带有给定键和值的数据
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.set({} as capDataStorageOptions);get
标题: “get”根据给定数据键检索一个数据值
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.get({} as capDataStorageOptions);remove
标题: “remove”根据给定键删除一个数据
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.remove({} as capDataStorageOptions);clear
标题: “clear”清除数据存储(删除所有键)
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.clear();iskey
标题:iskey检查数据键是否存在
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.iskey({} as capDataStorageOptions);keys
标题:keys获取数据键列表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.keys();values
标题:values获取数据值列表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.values();filtervalues
标题:filtervalues获取过滤键的数据值列表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.filtervalues({} as capFilterStorageOptions);keysvalues
标题:keysvalues获取数据键值对列表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.keysvalues();isTable
标题:isTable检查表是否存在
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.isTable({} as capTableStorageOptions);tables
标题:tables获取当前数据存储的表列表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.tables();deleteTable
标题:deleteTable删除表
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteTable({} as capTableStorageOptions);importFromJson
导入JSON从JSON导入数据库
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.importFromJson({} as capStoreImportOptions);isJsonValid
校验JSON对象校验JSON对象的有效性
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.isJsonValid({} as capStoreImportOptions);exportToJson
导出JSON将数据库导出为JSON对象
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.exportToJson();类型参考
类型参考capOpenStorageOptions
Section titled “SQLite存储选项”export interface capOpenStorageOptions { /** * The storage database name */ database?: string; // default: // ios, android: storageSQLite // web : storageIDB /** * The storage table name */ table?: string; // default: // ios, android: storage_table // web: storage_store /** * Set to true for database encryption */ encrypted?: boolean; // only for ios and android /*** * Set the mode for database encryption * ["encryption", "secret","newsecret"] */ mode?: string; // only for ios and android}capStorageOptions
Section titled “SQLite存储配置”export interface capStorageOptions { /** * The storage name */ database: string;}capDataStorageResult
Section titled “SQLite数据存储结果”export interface capDataStorageResult { /** * result set to true when successful else false */ result?: boolean; /** * a returned message */ message?: string;}capTableStorageOptions
Section titled “SQLite表格存储选项”export interface capTableStorageOptions { /** * The storage table name */ table: string;}capDataStorageOptions
Section titled “SQLite数据存储选项”export interface capDataStorageOptions { /** * The data name */ key: string; /** * The data value when required */ value?: string;}capValueResult
Section titled “SQLite值结果”export interface capValueResult { /** * the data value for a given data key */ value: string;}capKeysResult
Section titled “capKeysResult”export interface capKeysResult { /** * the data key list as an Array */ keys: string[];}capValuesResult
Section titled “capValuesResult”export interface capValuesResult { /** * the data values list as an Array */ values: string[];}capFilterStorageOptions
Section titled “capFilterStorageOptions”export interface capFilterStorageOptions { /** * The filter data for filtering keys * * ['%filter', 'filter', 'filter%'] for * [starts with filter, contains filter, ends with filter] */ filter: string;}capKeysValuesResult
Section titled “capKeysValuesResult”export interface capKeysValuesResult { /** * the data keys/values list as an Array of {key:string,value:string} */ keysvalues: any[];}capTablesResult
Section titled “capTablesResult”export interface capTablesResult { /** * the tables list as an Array */ tables: string[];}capStoreImportOptions
Section titled “capStoreImportOptions”export interface capStoreImportOptions { /** * Set the JSON object to import * */ jsonstring?: string;}数据源真相
标题:数据源真相本页面由插件生成 src/definitions.ts. 当公共 API 上游更改时,请重新运行同步。
继续从 Getting Started
标题:继续从 Getting Started如果您正在使用 Getting Started 来规划存储和文件处理,连接它到 使用 @capgo/capacitor-data-storage-sqlite 用于在使用 @capgo/capacitor-data-storage-sqlite 中的本机功能 @capgo/capacitor-data-storage-sqlite Capgo @capgo/capacitor-data-storage-sqlite Capgo @capgo/capacitor-file Capgo @capgo/capacitor-file 使用 Capgo @capgo/capacitor-file Capgo @capgo/capacitor-uploader @capgo/capacitor-uploader for the implementation detail in @capgo/capacitor-uploader.