はじめに
このプラグインのインストール手順と全マークダウンガイドを含む設定の質問をコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-fast-sql`
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/fast-sql/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.
CapgoのAI-Assistedセットアップを使用してプラグインをインストールできます。次のコマンドを使用して、CapgoスキルをAIツールに追加してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsManualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-fast-sql` plugin in my project.インストール
bun add @capgo/capacitor-fast-sqlbunx cap syncインポート
インポートimport { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';APIの概要
APIガイド切断
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });console.log('Connected on port:', conn.port);disconnect
データベース接続を閉じ、HTTPサーバーを停止します。ターミナル画面
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });getServerInfo
「getServerInfo」セクションHTTPサーバーのポートとトークンを取得して直接通信を行います。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });console.log('Server port:', info.port);execute
「execute」セクションCapacitor ブリッジを使用してシンプルなクエリを実行します (シンプルなクエリの場合)。 大規模なデータセットの場合、SQLConnectionクラスを使用してHTTPプロトコルを直接使用することでパフォーマンスが向上します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const result = await CapgoCapacitorFastSql.execute({ database: 'myapp', statement: 'SELECT * FROM users WHERE age > ?', params: [18]});console.log('Rows:', result.rows);beginTransaction
「beginTransaction」セクショントランザクションを開始します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });// Execute multiple operationsawait CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });commitTransaction
「commitTransaction」セクション現在のトランザクションをコミットします。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });rollbackTransaction
ロールバックトランザクショントランザクションをロールバックします。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
try { await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' }); // Operations... await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });} catch (error) { await CapgoCapacitorFastSql.rollbackTransaction({ database: 'myapp' });}configureWeb
Web特有の設定sql.js WASMモジュールのWeb特有の設定を構成します。
呼び出し 最初の first connect() 型参照
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
// Configure once at app startup (web only)await CapgoCapacitorFastSql.configureWeb({ sqlJsUrl: '/assets/sql-wasm.js', wasmUrl: '/assets/sql-wasm.wasm',});const db = await FastSQL.connect({ database: 'myapp' });SQLConnectionOptions
「SQLConnectionOptions」データベース接続オプション
export interface SQLConnectionOptions { /** * Database name (file will be created in app data directory) */ database: string;
/** * Enable encryption (iOS/Android only) */ encrypted?: boolean;
/** * Encryption key (required if encrypted is true) */ encryptionKey?: string;
/** * Read-only mode */ readOnly?: boolean;}SQLValue
「SQLValue」プラグインがサポートするSQL値の種類
export type SQLValue = string | number | boolean | null | Uint8Array;SQLResult
「SQLResult」SQLクエリの実行結果
export interface SQLResult { /** * Rows returned by the query (for SELECT statements) */ rows: SQLRow[];
/** * Number of rows affected by the query (for INSERT/UPDATE/DELETE) */ rowsAffected: number;
/** * ID of the last inserted row (for INSERT statements with auto-increment) */ insertId?: number;}IsolationLevel
「IsolationLevel」トランザクションの隔離レベル
export enum IsolationLevel { ReadUncommitted = 'READ UNCOMMITTED', ReadCommitted = 'READ COMMITTED', RepeatableRead = 'REPEATABLE READ', Serializable = 'SERIALIZABLE',}WebConfig
「WebConfig」セクションsql.js WASM モジュールの Web プラットフォーム設定 configureWeb() sql.js をローカルにバンドルしたパスから読み込む代わりに、デフォルトの CDN を使用します。
export interface WebConfig { /** * URL to the sql.js JavaScript file (`sql-wasm.js`). * When omitted, the plugin loads from the cdnjs CDN. * @example '/assets/sql-wasm.js' */ sqlJsUrl?: string;
/** * URL to the sql.js WebAssembly binary (`sql-wasm.wasm`). * When omitted, the plugin loads from the cdnjs CDN. * @example '/assets/sql-wasm.wasm' */ wasmUrl?: string;}SQLRow
「SQLRow」セクションSQL レコードの結果 - 列名でインデックスされた値
export interface SQLRow { [column: string]: SQLValue;}真実の源
「真実の源」セクションこのページはプラグインの src/definitions.ts公開 API がアップストリームで変更されたときに再度同期してください。
続けてGetting Started
「続けてGetting Started」というセクション「Getting Started」を使用している場合 はじめに 「Getting Started」を使用してダッシュボードとAPIの操作を計画するには、APIを接続します。 「@capgo/capacitor-fast-sql」を使用 「@capgo/capacitor-fast-sql」のネイティブ機能 「API Overview」の実装詳細 「API Overview」 Introduction 「Introduction」 「API Keys」 APIの実装詳細については Devices __CAPGO_KEEP_0__