はじめに
このプラグインのインストール手順と完全な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.
インストール
「Install」セクションAIアシストセットアップを使ってプラグインをインストールできます。以下のコマンドで、お使いのAIツールに Capgo スキルを追加してください:
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.手動セットアップを希望する場合は、以下のコマンドでプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
bun add @capgo/capacitor-data-storage-sqlitebunx cap syncインポート
「Import」セクションimport { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';クイックスタート
「Quick start」セクションimport { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({ database: 'app', encrypted: true });await CapgoCapacitorDataStorageSqlite.set({ key: 'session', value: JSON.stringify(session) });const { value } = await CapgoCapacitorDataStorageSqlite.get({ key: 'session' });例:名前空間付きテーブル
「例:名前空間付きテーブル」というタイトルのセクションawait CapgoCapacitorDataStorageSqlite.setTable({ table: 'drafts' });await CapgoCapacitorDataStorageSqlite.set({ key: 'invoice-42', value: draftJson });よくある落とし穴
「Common pitfalls」セクション- 使用前に開く: すべての読み書きには、開かれたストアのハンドルが必要です。
- 暗号化の範囲: 暗号化は iOS および Android のネイティブストアに適用され、Web の IndexedDB パスには適用されません。
- ログアウト時に閉じる:
clear()およびcloseStore()共有デバイスでのデータの不整合を防ぎます。
API の概要
「API 概要」セクションopenStore
「openStore」セクションストアを開く
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});closeStore
「closeStore」セクションStoreを閉じる
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.closeStore({ database: 'database' });isStoreOpen
「isStoreOpen」セクションStoreが開いているか確認する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreOpen({ database: 'database' });console.log(result);isStoreExists
「isStoreExists」セクションStoreが存在するか確認する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreExists({ database: 'database' });console.log(result);deleteStore
「deleteStore」セクションStoreを削除する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});setTable
「setTable」セクション既存のストアにテーブルを設定または追加する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.setTable({ table: 'table' });set
「set」セクション指定したキーと値でデータを保存する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.set({ key: 'key-123' });get
「get」セクション指定したデータキーに対応する値を取得する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.get({ key: 'key-123' });console.log(result);remove
「remove」セクション指定したキーのデータを削除する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.remove({ key: 'key-123' });clear
「clear」セクションデータストアのクリア(全キーの削除)
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.clear();iskey
「iskey」セクションデータキーの存在確認
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.iskey({ key: 'key-123' });console.log(result);keys
「keys」セクションデータキー一覧の取得
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keys();console.log(result);values
「values」セクションデータ値一覧の取得
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.values();console.log(result);filtervalues
「filtervalues」セクションフィルターキーのデータ値リストを取得する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.filtervalues({ filter: 'filter' });console.log(result);keysvalues
「keysvalues」セクションデータのキー/値ペアのリストを取得する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keysvalues();console.log(result);isTable
「isTable」セクションテーブルが存在するか確認する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isTable({ table: 'table' });console.log(result);tables
「tables」セクション現在のストアのテーブル一覧を取得する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.tables();console.log(result);deleteTable
「deleteTable」セクションテーブルを削除する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteTable({ table: 'table' });importFromJson
「importFromJson」セクションJSONからデータベースをインポートする
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.importFromJson({ jsonstring: 'jsonstring' });console.log(result);isJsonValid
「isJsonValid」セクションJSONオブジェクトの妥当性を確認する
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isJsonValid({ jsonstring: 'jsonstring' });console.log(result);exportToJson
「exportToJson」セクションデータベースをJSONオブジェクトにエクスポートする
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.exportToJson();console.log(result);型リファレンス
「型リファレンス」セクションcapOpenStorageOptions
「capOpenStorageOptions」セクション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
「capStorageOptions」セクションexport interface capStorageOptions { /** * The storage name */ database: string;}capDataStorageResult
「capDataStorageResult」セクションexport interface capDataStorageResult { /** * result set to true when successful else false */ result?: boolean; /** * a returned message */ message?: string;}capTableStorageOptions
「capTableStorageOptions」セクションexport interface capTableStorageOptions { /** * The storage table name */ table: string;}capDataStorageOptions
「capDataStorageOptions」セクションexport interface capDataStorageOptions { /** * The data name */ key: string; /** * The data value when required */ value?: string;}capValueResult
「capValueResult」セクションexport interface capValueResult { /** * the data value for a given data key */ value: string;}capKeysResult
「capKeysResult」セクションexport interface capKeysResult { /** * the data key list as an Array */ keys: string[];}capValuesResult
「capValuesResult」セクションexport interface capValuesResult { /** * the data values list as an Array */ values: string[];}capFilterStorageOptions
「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
「capKeysValuesResult」セクションexport interface capKeysValuesResult { /** * the data keys/values list as an Array of {key:string,value:string} */ keysvalues: any[];}capTablesResult
「capTablesResult」セクションexport interface capTablesResult { /** * the tables list as an Array */ tables: string[];}capStoreImportOptions
「capStoreImportOptions」セクションexport interface capStoreImportOptions { /** * Set the JSON object to import * */ jsonstring?: string;}信頼できる情報源
「信頼できる情報源」セクションこのページはプラグインの src/definitions.tsから生成されています。上流で公開 API が変更されたら、sync を再実行してください。
Getting Started から続ける
「Getting Started からの続き」セクション以下を使用している場合: はじめに ストレージとファイル処理を計画するには、次と連携させます @capgo/capacitor-data-storage-sqlite の使い方 @capgo/capacitor-data-storage-sqlite を使用したネイティブ機能について @capgo/capacitor-data-storage-sqlite @capgo/capacitor-data-storage-sqlite の実装の詳細については、 @capgo/capacitor-file @capgo/capacitor-file の実装詳細について @capgo/capacitor-file の使用 @capgo/capacitor-file を使用したネイティブ機能、および @capgo/capacitor-uploader @capgo/capacitor-uploader. の実装詳細