시작
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
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 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 프로토콜을 직접 사용하세요.)
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
beginTransaction현재 트랜잭션을 커밋하세요.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });rollbackTransaction
beginTransaction현재 거래를 되돌리십시오.
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
configureWebSQL.js WASM 모듈의 웹 관련 옵션을 구성하십시오.
이것을 호출하십시오. 이전 첫 번째 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
SQLResultSQL 쿼리 실행 결과.
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 모듈을 위한 것입니다. 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
SQLRowSQLRow - 열 이름에 따라 인덱싱된 값.
export interface SQLRow { [column: string]: SQLValue;}실질적인 진실
실질적인 진실이 페이지는 플러그인의 src/definitions.ts을 다시 동기화할 때 upstream의 API가 변경되면.
시작부터 계속
시작부터 계속이 기능을 사용 중이라면 시작하기 대시보드와 API 연산을 계획하고 시작하기 위해, API을 연결하세요. Using @capgo/capacitor-fast-sql for the native capability in Using @capgo/capacitor-fast-sql, API Overview for the implementation detail in API Overview, __CAPGO_KEEP_0__ Keys __CAPGO_KEEP_0__ Keys API Keys API __CAPGO_KEEP_1__ 장치에 대한 구현 세부 정보.