Zum Hauptinhalt springen
@capgo/capacitor-sql Daten und Speicher Offene Quelle

SQL-Abfrage Capacitor-Plugin

Hocheffiziente native SQLite mit benutzerdefinierter Protokoll für effiziente Synchronisationsoperationen und IndexedDB-Ersatz

Installieren

bun add @capgo/capacitor-fast-sql bunx cap sync
npm, pnpm oder yarn
  • npm install @capgo/capacitor-fast-sql
  • pnpm add @capgo/capacitor-fast-sql
  • yarn add @capgo/capacitor-fast-sql

Guide

Wie man Fast SQL in Capacitor verwendet

Wie man Fast SQL in __CAPGO_KEEP_0__ verwendet

Herunterladen Sie die Capgo App, dann scannen Sie die QR-code-Code.

Vorschau-Link für das Fast SQL-code

Verwendung von @capgo/capacitor-fast-sql

Schnelles SQL-Plugin für eine hohe Leistung des SQLite-Datenbankzugriffs

Installieren

bun add @capgo/capacitor-fast-sql
bunx cap sync

bunx cap sync kopiert die native code des Plugins in Ihre native Projekte. Führen Sie es erneut durch, nachdem Sie das Plugin aktualisiert haben.

Importieren

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

API im Überblick

Methode Beschreibung
connect Initialisieren Sie die Datenbankverbindung und starten Sie den HTTP-Server.
disconnect Schließen Sie die Datenbankverbindung und stoppen Sie den HTTP-Server.
getServerInfo Rufen Sie den HTTP-Server-Port und den Token für direkte Kommunikation ab.
execute Über die Capacitor-Brücke (für einfache Abfragen) ausführen Sie eine SQL-Anfrage. Für eine bessere Leistung bei großen Datensätzen verwenden Sie direkt den HTTP-Protokoll über die SQLConnection-Klasse.
beginTransaction Beginnen Sie eine Datenbanktransaktion.
commitTransaction Bestätigen Sie die aktuelle Transaktion.
rollbackTransaction Rollen Sie die aktuelle Transaktion zurück.
configureWeb Konfigurieren Sie web-spezifische Optionen für das offizielle SQLite-Wasm-Modul.

Beispiele

connect()

Initialisieren Sie die Datenbankverbindung und starten Sie den HTTP-Server.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

const conn = await CapgoCapacitorFastSql.connect({ database: 'myapp' });
console.log('Connected on port:', conn.port);

disconnect()

Schließen Sie die Datenbankverbindung und stoppen Sie den HTTP-Server.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.disconnect({ database: 'myapp' });

getServerInfo()

Erhalten Sie den HTTP-Server-Port und den Token für direkte Kommunikation.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

const info = await CapgoCapacitorFastSql.getServerInfo({ database: 'myapp' });
console.log('Server port:', info.port);

execute()

Über die Capacitor-Brücke (für einfache Abfragen) ausführen. Für eine bessere Leistung bei großen Datensätzen verwenden Sie den HTTP-Protokoll direkt über die SQLConnection-Klasse.

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()

Beginnen Sie eine Datenbanktransaktion.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.beginTransaction({ database: 'myapp' });
// Execute multiple operations
await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });

commitTransaction()

Bestätigen Sie die aktuelle Transaktion.

import { CapgoCapacitorFastSql } from '@capgo/capacitor-fast-sql';

await CapgoCapacitorFastSql.commitTransaction({ database: 'myapp' });

Die Tabelle oben listet die 8 Kernmethoden. Helfer für Listener und Versionen sowie die vollständige Vertragsstruktur jeder Methode sind in der GitHub-Repository.

Vollständige Referenz

Fortsetzen Sie mit der Verwendung von @capgo/capacitor-fast-sql

Wenn Sie bereits Mit @capgo/capacitor-fast-sql um den Speicher und die Dateiverwaltung zu planen und zu verbinden um @capgo/capacitor-fast-sql zu verbinden um die Implementierungsdetails in @capgo/capacitor-fast-sql zu erhalten Getting Started um die Implementierungsdetails in Einstieg zu erhalten Mit @capgo/capacitor-data-storage-sqlite um die Implementierungsdetails in @capgo/capacitor-data-storage-sqlite zu erhalten Mit @capgo/capacitor-data-storage-sqlite um die native Fähigkeit in Mit @capgo/capacitor-data-storage-sqlite zu erhalten und Mit @capgo/capacitor-file um die Implementierungsdetails in @capgo/capacitor-file zu erhalten

FAQ

FAQ für den Schnell-SQL-Plugin

Wie installiere ich die Fast SQL-Plugin in einer Capacitor-Anwendung?

Run "bun add @capgo/capacitor-fast-sql" (or "npm install @capgo/capacitor-fast-sql"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-fast-sql" in your app code.

Arbeitet @capgo/capacitor-fast-sql mit React, Vue und Angular?

Ja. Fast SQL ist ein Capacitor-Paket, also funktioniert es mit jedem Webframework, das innerhalb von Capacitor läuft, einschließlich Ionic, React, Vue, Angular, Svelte und plain JavaScript.

Welche Capacitor-Version unterstützt @capgo/capacitor-fast-sql?

Capgo-Plugins folgen der Capacitor-Version: verwenden Sie die Plugin-Major-Version, die Ihrem Capacitor-Major-Version entspricht (z.B. Plugin v8 mit Capacitor 8). Die Kompatibilitäts-Tabelle im GitHub-README listet die unterstützten Versionen auf.

ist @capgo/capacitor-fast-sql kostenlos und Open-Source?

Ja. Der Quellcode von code ist öffentlich auf GitHub unter https://github.com/Cap-go/capacitor-fast-sql/ verfügbar und das Paket kann kostenlos installiert werden von npm. Bug-Reports und Pull-Requests sind willkommen.

Kann ich code mit Fast SQL aktualisieren, ohne eine App-Store-Überprüfung?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Schnelle SQL-Änderungen ohne Wartezeit auf die App-Überprüfung

Sobald das Plugin in Ihrem Store-Builder integriert ist, drücken Capgo live Updates Ihre JavaScript-, HTML- und CSS-Änderungen an die Benutzer in Minuten aus.

Starten Sie mit Capgo