Prise en main
Copiez un prompt de configuration incluant les étapes d'installation et le guide markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-data-storage-sqlite`
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/data-storage-sqlite/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.
Installer
Section intitulée « Installation »Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite le prompt suivant :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-data-storage-sqlite` plugin in my project.Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :
bun add @capgo/capacitor-data-storage-sqlitebunx cap syncImporter
Section intitulée « Import »import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';Démarrage rapide
Section intitulée « Démarrage rapide »import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({ database: 'app', encrypted: true });await CapgoCapacitorDataStorageSqlite.set({ key: 'session', value: JSON.stringify(session) });const { value } = await CapgoCapacitorDataStorageSqlite.get({ key: 'session' });Exemple : table avec namespace
Section intitulée « Exemple : table avec namespace »await CapgoCapacitorDataStorageSqlite.setTable({ table: 'drafts' });await CapgoCapacitorDataStorageSqlite.set({ key: 'invoice-42', value: draftJson });Erreurs courantes
Section intitulée « Erreurs courantes »- Ouvrir avant utilisation: chaque lecture ou écriture nécessite un handle de store ouvert.
- Portée du chiffrement: le chiffrement s'applique aux stores natifs iOS et Android, pas au chemin IndexedDB du web.
- Fermer lors de la déconnexion:
clear()de plus,closeStore()évite les données obsolètes sur les appareils partagés.
Aperçu de API
Section intitulée « Aperçu API »openStore
Section intitulée « openStore »Ouvrir un store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});closeStore
Section intitulée « closeStore »Fermer le store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.closeStore({ database: 'database' });isStoreOpen
Section intitulée « isStoreOpen »Vérifier si le store est ouvert
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreOpen({ database: 'database' });console.log(result);isStoreExists
Section intitulée « isStoreExists »Vérifier si le store existe
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreExists({ database: 'database' });console.log(result);deleteStore
Section intitulée « deleteStore »Supprimer un store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});setTable
Section intitulée « setTable »Définir ou ajouter une table à un store existant
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.setTable({ table: 'table' });Stocker une donnée avec une clé et une valeur données
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.set({ key: 'key-123' });Récupérer la valeur d'une donnée pour une clé donnée
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.get({ key: 'key-123' });console.log(result);Supprimer une donnée avec une clé donnée
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.remove({ key: 'key-123' });Vider le Data Store (supprimer toutes les clés)
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.clear();Vérifier si une clé de donnée existe
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.iskey({ key: 'key-123' });console.log(result);Récupérer la liste des clés de données
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keys();console.log(result);Récupérer la liste des valeurs
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.values();console.log(result);filtervalues
Section intitulée « filtervalues »Récupérer la liste des valeurs pour les clés de filtrage
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.filtervalues({ filter: 'filter' });console.log(result);keysvalues
Section intitulée « keysvalues »Récupérer la liste des paires clé/valeur
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keysvalues();console.log(result);Vérifier si une table existe
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isTable({ table: 'table' });console.log(result);Récupérer la liste des tables du store actuel
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.tables();console.log(result);deleteTable
Section intitulée « deleteTable »Supprimer une table
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteTable({ table: 'table' });importFromJson
Section intitulée « importFromJson »Importer une base de données depuis un JSON
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.importFromJson({ jsonstring: 'jsonstring' });console.log(result);isJsonValid
Section intitulée « isJsonValid »Vérifier la validité d'un objet JSON
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isJsonValid({ jsonstring: 'jsonstring' });console.log(result);exportToJson
Section intitulée « exportToJson »Exporter la base de données vers un objet JSON
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.exportToJson();console.log(result);Référence de type
Section intitulée « Référence de type »capOpenStorageOptions
Section intitulée « capOpenStorageOptions »export interface capOpenStorageOptions { /** * The storage database name */ database?: string; // default: // ios, android: storageSQLite // web : storageIDB /** * The storage table name */ table?: string; // default: // ios, android: storage_table // web: storage_store /** * Set to true for database encryption */ encrypted?: boolean; // only for ios and android /*** * Set the mode for database encryption * ["encryption", "secret","newsecret"] */ mode?: string; // only for ios and android}capStorageOptions
Section intitulée « capStorageOptions »export interface capStorageOptions { /** * The storage name */ database: string;}capDataStorageResult
Section intitulée « capDataStorageResult »export interface capDataStorageResult { /** * result set to true when successful else false */ result?: boolean; /** * a returned message */ message?: string;}capTableStorageOptions
Section intitulée « capTableStorageOptions »export interface capTableStorageOptions { /** * The storage table name */ table: string;}capDataStorageOptions
Section intitulée « capDataStorageOptions »export interface capDataStorageOptions { /** * The data name */ key: string; /** * The data value when required */ value?: string;}capValueResult
Section intitulée « capValueResult »export interface capValueResult { /** * the data value for a given data key */ value: string;}capKeysResult
Section intitulée « capKeysResult »export interface capKeysResult { /** * the data key list as an Array */ keys: string[];}capValuesResult
Section intitulée « capValuesResult »export interface capValuesResult { /** * the data values list as an Array */ values: string[];}capFilterStorageOptions
Section intitulée « capFilterStorageOptions »export interface capFilterStorageOptions { /** * The filter data for filtering keys * * ['%filter', 'filter', 'filter%'] for * [starts with filter, contains filter, ends with filter] */ filter: string;}capKeysValuesResult
Section intitulée « capKeysValuesResult »export interface capKeysValuesResult { /** * the data keys/values list as an Array of {key:string,value:string} */ keysvalues: any[];}capTablesResult
Section intitulée « capTablesResult »export interface capTablesResult { /** * the tables list as an Array */ tables: string[];}capStoreImportOptions
Section intitulée « capStoreImportOptions »export interface capStoreImportOptions { /** * Set the JSON object to import * */ jsonstring?: string;}Source de vérité
Section intitulée « Source de vérité »Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.
Continuer depuis Getting Started
Section intitulée « Continuer après Prise en main »Si vous utilisez Prise en main pour planifier le stockage et la gestion des fichiers, connectez-l’à Utiliser @capgo/capacitor-data-storage-sqlite pour la capacité native dans Utiliser @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-data-storage-sqlite pour les détails d'implémentation dans @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-file pour les détails d'implémentation dans @capgo/capacitor-file, Utiliser @capgo/capacitor-file pour la capacité native dans Utiliser @capgo/capacitor-file, et @capgo/capacitor-uploader pour les détails d'implémentation dans @capgo/capacitor-uploader.