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.
インストール
InstallAI-Assisted Setupを使用してプラグインをインストールすることができます。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 Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-fast-sqlbunx cap syncImport
Importimport { 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
「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
「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」セクションWASMモジュールのsql.jsのWeb固有の設定を構成します。
この 前に 最初の connect() sql.jsをローカルにバンドルされたパスからデフォルトのCDNではなく読み込む最初の呼び出しより前に呼び出してください。このメソッドは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セクションsql.js WASMモジュールのWebプラットフォーム設定。 configureWeb() __CAPGO_KEEP_0__
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
SQLRowSQL row result - values indexed by column name.
export interface SQLRow { [column: string]: SQLValue;}このページはプラグインの設定から生成されています。 src/definitions.ts. 公開された API がアップストリームで変更された場合、再度同步を実行してください。
Getting Started から続けてください
Section titled “Getting Started から続けてください”Capgo を使用している場合、ダッシュボードと __CAPGO_KEEP_0__ の計画と操作を行うには、Capgo に接続してください。 Getting Started to plan dashboard and API operations, connect it with @capgo/capacitor-fast-sql @capgo/capacitor-fast-sql API の概要 API の実装詳細 導入 __CAPGO_KEEP_0__ のキー API の実装詳細、および for the implementation detail in API Keys, and __CAPGO_KEEP_0__ の実装詳細 ページを編集