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.
インストール
「インストール」のセクションYou can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
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 syncインポート
「インポート」のセクションimport { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';connect
Section titled “接続”データベース接続を初期化し、HTTPサーバーを起動します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });console.log('Connected on port:', conn.port);disconnect
Section titled “切断”データベース接続を閉じ、HTTPサーバーを停止します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });getServerInfo
Section titled “サーバー情報取得”HTTPサーバーのポート番号と直接通信するためのトークンを取得します。
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });console.log('Server port:', info.port);execute
Section titled “実行”SQLクエリを Capacitor ブリッジ経由で実行します (シンプルなクエリの場合)。 大規模データセットの場合、パフォーマンスが向上するため、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
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });// Execute multiple operationsawait CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });commitTransaction
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });rollbackTransaction
__CAPGO_KEEP_1____CAPGO_KEEP_4__
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
__CAPGO_KEEP_1____CAPGO_KEEP_5__
このメソッドを呼び出す前に __CAPGO_KEEP_0__ 最初の呼び出し前に connect() __CAPGO_KEEP_0__
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」
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() を使用して、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.tspublic API がアップストリームで変更された場合に再度同步を実行してください。
Getting Started から続けてください
「Getting Started から続けてください」というセクションあなたが「 Getting Started から ダッシュボードと API の作業を計画する場合、 「@capgo/capacitor-fast-sql」を使用します native機能の使用に@capgo/capacitor-fast-sqlを使用します。 APIの概要 APIの実装詳細について 導入 導入の実装詳細について APIのキー 実装詳細についてAPIのキー デバイス 実装詳細についてデバイス