Iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
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.
Installazione
Sezione intitolata “Installazione”bun add @capgo/capacitor-fast-sqlbunx cap syncImporta
Sezione intitolata “Importa”import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';API Panoramica
Sezione intitolata “API Panoramica”Inizializza la connessione al database e avvia il server HTTP.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });console.log('Connected on port:', conn.port);disconnect
Sezione intitolata “disconnessione”Chiudi la connessione al database e fermi il server HTTP.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });getServerInfo
Sezione intitolata “informazioni sul server”Ottieni il numero di porta e il token del server HTTP per comunicazione diretta.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });console.log('Server port:', info.port);execute
Sezione intitolata “esegui”Eseguire una query SQL tramite Capacitor ponte (per query semplici). Per una maggiore prestazione con grandi set di dati, utilizzare il protocollo HTTP direttamente tramite la classe 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
Sottosezione intitolata “beginTransaction”Iniziare una transazione di database.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });// Execute multiple operationsawait CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });commitTransaction
Sottosezione intitolata “commitTransaction”Confermare la transazione corrente.
import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });rollbackTransaction
Sottosezione intitolata “rollbackTransaction”Annullare la transazione corrente.
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
Sottosezione intitolata “configureWeb”Configura opzioni specifiche per il web per il modulo sql.js WASM.
Chiamare questo prima della prima connect() chiamata per caricare sql.js da un percorso bundle locale anziché il CDN predefinito. Questo metodo è un no-op
su iOS e 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' });Riferimento di tipo
Sezione intitolata “Riferimento di tipo”SQLConnectionOptions
Sezione intitolata “Opzioni di connessione SQL”Opzioni di connessione al database.
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
Sezione intitolata “Valore SQL”Tipi di valori SQL supportati dal plugin.
export type SQLValue = string | number | boolean | null | Uint8Array;SQLResult
Sezione intitolata “SQLResult”Risultato dell'esecuzione di una query 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
Sezione intitolata “IsolationLevel”Livelli di isolamento della transazione.
export enum IsolationLevel { ReadUncommitted = 'READ UNCOMMITTED', ReadCommitted = 'READ COMMITTED', RepeatableRead = 'REPEATABLE READ', Serializable = 'SERIALIZABLE',}WebConfig
Sezione intitolata “WebConfig”Configurazione della piattaforma web per il modulo sql.js WASM. Utilizzare con configureWeb() per caricare sql.js da un percorso localmente bundle invece del CDN predefinito.
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;}Risultato di riga SQL - valori indicizzati dal nome della colonna.
export interface SQLRow { [column: string]: SQLValue;}Punto di Riferimento
Sezione intitolata “Punto di Riferimento”Questa pagina è generata dal plugin’s src/definitions.ts. Riavvia la sincronizzazione quando le informazioni pubbliche API cambiano in fase di sviluppo.
Continua da Iniziare
Sezione intitolata “Continua da Iniziare”Se stai utilizzando Iniziare per pianificare dashboard e API operazioni, connettilo con Usando @capgo/capacitor-fast-sql per la capacità nativa in Usando @capgo/capacitor-fast-sql, Panoramica di API per il dettaglio di implementazione in Panoramica di API, Introduzione per il dettaglio di implementazione in Introduzione, API Chiavi per il dettaglio di implementazione in API Chiavi, e Dispositivi per il dettaglio di implementazione in Dispositivi.