Panduan Memulai
Salin prompt setup yang berisi langkah install dan panduan markdown lengkap untuk plugin ini.
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.
Anda bisa menggunakan AI-Assisted Setup kami untuk menginstal plugin ini. Tambahkan skill Capgo ke tool AI Anda dengan command berikut:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsLalu gunakan prompt berikut:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-data-storage-sqlite` plugin in my project.Jika Anda lebih memilih Manual Setup, instal plugin dengan menjalankan perintah berikut dan ikuti petunjuk khusus platform di bawah ini:
bun add @capgo/capacitor-data-storage-sqlitebunx cap syncimport { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';Mulai cepat
Bagian berjudul “Mulai cepat”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' });Contoh: tabel namespaced
Bagian berjudul “Contoh: tabel namespaced”await CapgoCapacitorDataStorageSqlite.setTable({ table: 'drafts' });await CapgoCapacitorDataStorageSqlite.set({ key: 'invoice-42', value: draftJson });Kesalahan umum
Bagian berjudul “Kesalahan umum”- Buka sebelum digunakan: setiap operasi baca atau tulis mengharapkan handle store yang terbuka.
- Cakupan enkripsi: enkripsi berlaku untuk store native iOS dan Android, bukan jalur IndexedDB web.
- Tutup saat logout:
clear()pluscloseStore()mencegah data usang pada perangkat bersama.
Ringkasan API
Bagian berjudul “Ikhtisar API”openStore
Bagian berjudul “openStore”Buka Store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});closeStore
Bagian berjudul “closeStore”Tutup Store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.closeStore({ database: 'database' });isStoreOpen
Bagian berjudul “isStoreOpen”Cek apakah Store sudah terbuka
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreOpen({ database: 'database' });console.log(result);isStoreExists
Bagian berjudul “isStoreExists”Cek apakah Store ada
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreExists({ database: 'database' });console.log(result);deleteStore
Bagian berjudul “deleteStore”Hapus store
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteStore({ database: 'database', table: 'table', encrypted: false, mode: 'encryption', autoVacuum: 'none',});setTable
Bagian berjudul “setTable”Atur atau tambahkan tabel ke store yang sudah ada
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.setTable({ table: 'table' });Simpan data dengan key dan value yang diberikan
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.set({ key: 'key-123' });Ambil nilai data untuk key data yang diberikan
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.get({ key: 'key-123' });console.log(result);remove
Bagian berjudul “remove”Hapus data dengan key yang diberikan
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.remove({ key: 'key-123' });Kosongkan Data Store (hapus semua key)
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.clear();Cek apakah data key ada
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.iskey({ key: 'key-123' });console.log(result);Ambil daftar data key
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keys();console.log(result);values
Bagian berjudul “values”Dapatkan daftar nilai data
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.values();console.log(result);filtervalues
Bagian berjudul “filtervalues”Dapatkan daftar nilai data untuk kunci filter
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.filtervalues({ filter: 'filter' });console.log(result);keysvalues
Bagian berjudul “keysvalues”Dapatkan daftar pasangan kunci/nilai data
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keysvalues();console.log(result);isTable
Bagian berjudul “isTable”Periksa apakah tabel ada
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isTable({ table: 'table' });console.log(result);tables
Bagian berjudul “tables”Dapatkan daftar tabel untuk store saat ini
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.tables();console.log(result);deleteTable
Bagian berjudul “deleteTable”Hapus tabel
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteTable({ table: 'table' });importFromJson
Bagian berjudul “importFromJson”Impor database dari JSON
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.importFromJson({ jsonstring: 'jsonstring' });console.log(result);isJsonValid
Bagian berjudul “isJsonValid”Periksa validitas objek JSON
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isJsonValid({ jsonstring: 'jsonstring' });console.log(result);exportToJson
Bagian berjudul “exportToJson”Ekspor database yang diberikan ke JSON Object
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.exportToJson();console.log(result);Referensi Tipe
Bagian berjudul “Referensi Tipe”capOpenStorageOptions
Bagian berjudul “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
Bagian berjudul “capStorageOptions”export interface capStorageOptions { /** * The storage name */ database: string;}capDataStorageResult
Bagian berjudul “capDataStorageResult”export interface capDataStorageResult { /** * result set to true when successful else false */ result?: boolean; /** * a returned message */ message?: string;}capTableStorageOptions
Bagian berjudul “capTableStorageOptions”export interface capTableStorageOptions { /** * The storage table name */ table: string;}capDataStorageOptions
Bagian berjudul “capDataStorageOptions”export interface capDataStorageOptions { /** * The data name */ key: string; /** * The data value when required */ value?: string;}capValueResult
Bagian berjudul “capValueResult”export interface capValueResult { /** * the data value for a given data key */ value: string;}capKeysResult
Bagian berjudul “capKeysResult”export interface capKeysResult { /** * the data key list as an Array */ keys: string[];}capValuesResult
Bagian berjudul “capValuesResult”export interface capValuesResult { /** * the data values list as an Array */ values: string[];}capFilterStorageOptions
Bagian berjudul “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
Bagian berjudul “capKeysValuesResult”export interface capKeysValuesResult { /** * the data keys/values list as an Array of {key:string,value:string} */ keysvalues: any[];}capTablesResult
Bagian berjudul “capTablesResult”export interface capTablesResult { /** * the tables list as an Array */ tables: string[];}capStoreImportOptions
Bagian berjudul “capStoreImportOptions”export interface capStoreImportOptions { /** * Set the JSON object to import * */ jsonstring?: string;}Sumber Kebenaran
Bagian berjudul “Sumber Kebenaran”Halaman ini dibuat dari plugin src/definitions.ts. Jalankan ulang sync saat API publik berubah di upstream.
Lanjutkan dari Getting Started
Bagian berjudul “Lanjutkan dari Getting Started”Jika Anda menggunakan Panduan Memulai untuk merencanakan penyimpanan dan penanganan file, hubungkan dengan Menggunakan @capgo/capacitor-data-storage-sqlite untuk kapabilitas native di Menggunakan @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-data-storage-sqlite untuk detail implementasi di @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-file untuk detail implementasi di @capgo/capacitor-file, Menggunakan @capgo/capacitor-file untuk kemampuan native di Menggunakan @capgo/capacitor-file, dan @capgo/capacitor-uploader untuk detail implementasi di @capgo/capacitor-uploader.