Getting Started
このプラグインのインストール手順とフルマークダウンガイドのセットアッププロンプトをコピーできます。
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アシストセットアップを使用してプラグインをインストールできます。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-fast-sql` plugin in my project.Manualセットアップを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-fast-sqlbunx cap syncインポート
「インポート」セクションimport { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';API オーバービュー
「API オーバービュー」セクションconnect
「接続」セクションデータベース接続を初期化し、HTTPサーバーを起動します。
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
「サーバー情報取得」セクションHTTPサーバー ポートとトークンを直接通信するために取得する。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });console.log('Server port:', info.port);execute
「実行」セクション単純なクエリの場合、Capacitor ブリッジを介してSQLクエリを実行します。 大規模なデータセットの場合、パフォーマンスが向上するため、HTTPプロトコルを直接使用するSQLConnectionクラスを使用することをお勧めします。
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
「トランザクション開始」セクショントランザクションを開始します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });// Execute multiple operationsawait CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });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
「configureWeb」SQL.js WASM モジュールのウェブ固有のオプションを設定
この呼び出し 前 最初の connect() ローカルにバンドルされたパスから sql.js をロードする最初の呼び出し。このメソッドは iOS と Android で何も実行されません。
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
「隔離レベル」のセクショントランザクションの隔離レベル。
export enum IsolationLevel { ReadUncommitted = 'READ UNCOMMITTED', ReadCommitted = 'READ COMMITTED', RepeatableRead = 'REPEATABLE READ', Serializable = 'SERIALIZABLE',}WebConfig
「WebConfig」のセクションWebプラットフォームの設定ファイルは、sql.js WASMモジュールのために使用します。 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. Re-run the sync when the public API changes upstream.
パブリック__CAPGO_KEEP_0__がアップストリームで変更されたときに、再度Syncを実行してください。
Getting Startedから続けてくださいCapgoを使用している場合 はじめに ダッシュボードとAPIの作業を計画するには、 Capgoの@capgo/capacitor-fast-sqlを使用します Capgoの@capgo/capacitor-fast-sqlのネイティブ機能について APIの概要 APIの実装詳細について 概要 __CAPGO_KEEP_0__の実装詳細について APIのキー APIの実装詳細について デバイス デバイスの実装詳細について。