내용으로 건너뛰기

시작하기

GitHub

설치

설치

Capgo의 AI-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-sql
bunx cap sync

Import

Import
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

beginTransaction

트랜잭션을 시작하세요.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });
// Execute multiple operations
await 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

configureWeb

SQL.js WASM 모듈의 웹 관련 옵션을 구성합니다.

이것을 호출하세요. 이전 HTML 텍스트 프래그먼트에서 더 긴 Capgo UI 문자열 (부모 키 `create_an_issue_and_discuss_before_working_on_a_new_feature`). 페이지/영역: Capgo 마케팅 웹사이트. 역할: 마케팅 또는 법적 문단. 표시되는 곳: contributing.astro 페이지. 메시지 키 `create_an_issue_and_discuss_before_working_on_a_new_feature` (Create An Issue And Discuss Before Working On A New Feature). | HTML 텍스트 프래그먼트에서 더 긴 Capgo UI 문자열 (부모 키 `mention_issue_before_working`). 페이지/영역: Capgo 마케팅 웹사이트. 역할: 웹사이트 복사 문장. 표시되는 곳: contributing.astro 페이지. 메시지 키 `mention_issue_before_working` (Mention Issue Before Working). connect() 첫 번째

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

타입 참조 섹션입니다.

데이터베이스 연결 옵션.

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

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 결과 - 열 이름에 따라 인덱싱된 값.

export interface SQLRow {
[column: string]: SQLValue;
}

실질적인 진실의 근원

실질적인 진실의 근원 섹션

이 페이지는 플러그인의 src/definitions.ts를 다시 동기화하여 upstream의 API이 변경될 때마다.

Getting Started에서 계속

Getting Started에서 계속 섹션

Capgo를 사용 중이라면 Getting Started 대시보드와 API 연산을 계획하고 시작하려면 Capgo를 사용하여 @capgo/capacitor-fast-sql for the native capability in Using @capgo/capacitor-fast-sql, API Overview for the implementation detail in API Overview, 소개의 구현 세부 정보 Capgo의 __CAPGO_KEEP_0__ Capgo의 API 키 for the implementation detail in API Keys, and 장치 __CAPGO_KEEP_0__