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.
설치
설치bun add @capgo/capacitor-fast-sqlbunx cap syncImport
Importimport { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';API 개요
API 개요 제목connect
__CAPGO_KEEP_0__ 연결데이터베이스 연결을 초기화하고 HTTP 서버를 시작합니다.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });console.log('Connected on port:', conn.port);disconnect
__CAPGO_KEEP_0__ 연결 해제데이터베이스 연결을 종료하고 HTTP 서버를 중지합니다.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });getServerInfo
__CAPGO_KEEP_0__ 서버 정보HTTP 서버 포트와 직접 통신하기 위한 토큰을 가져옵니다.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });console.log('Server port:', info.port);execute
__CAPGO_KEEP_0__ 실행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
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 섹션__CAPGO_KEEP_0__을 위한 웹 특정 옵션을 구성합니다.
__CAPGO_KEEP_1__를 호출하세요. __CAPGO_KEEP_2__ __CAPGO_KEEP_3__에 대한 __CAPGO_KEEP_1__ 호출 전에 sql.js를 로컬로 패키징된 경로 대신 기본 CDN에서 로드하기 위해 sql.js WASM 모듈을 사용합니다. 이 메서드는 iOS 및 Android에서 비어 있습니다. connect() __CAPGO_KEEP_4__
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' });__CAPGO_KEEP_6__
__CAPGO_KEEP_7__SQLConnectionOptions
__CAPGO_KEEP_8____CAPGO_KEEP_9__
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
__CAPGO_KEEP_11____CAPGO_KEEP_0__ 지원하는 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
WebConfigsql.js WASM 모듈의 웹 플랫폼 설정을 사용하여 configureWeb() __CAPGO_KEEP_0__를 사용하여 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 row 결과 - 열 이름에 색인된 값.
export interface SQLRow { [column: string]: SQLValue;}실제 데이터 원본
실제 데이터 원본 섹션 제목이 페이지는 플러그인의 src/definitions.ts. 업스트림에서 pubic API이 변경될 때 다시 싱크를 실행하세요.
Getting Started에서 계속
Getting Started에서 계속 섹션 제목Capgo를 사용하는 경우 Getting Started to plan dashboard and API operations, connect it with @capgo/capacitor-fast-sql @capgo/capacitor-fast-sql API 개요 API 개요 구현 세부 사항 소개 소개 구현 세부 사항 API 키 API 키 구현 세부 사항 및 장치 장치 구현 세부 사항.