Skip to content

Getting Started

GitHub

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

Terminal window
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-data-storage-sqlite` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

Terminal window
bun add @capgo/capacitor-data-storage-sqlite
bunx cap sync
import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';

Open a store

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.openStore({
database: 'database',
table: 'table',
encrypted: false,
mode: 'encryption',
autoVacuum: 'none',
});

Close the Store

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.closeStore({ database: 'database' });

Check if the Store is opened

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreOpen({ database: 'database' });
console.log(result);

Check if the Store exists

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isStoreExists({ database: 'database' });
console.log(result);

Delete a store

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteStore({
database: 'database',
table: 'table',
encrypted: false,
mode: 'encryption',
autoVacuum: 'none',
});

Set or Add a table to an existing store

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.setTable({ table: 'table' });

Store a data with given key and value

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.set({ key: 'key-123' });

Retrieve a data value for a given data key

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.get({ key: 'key-123' });
console.log(result);

Remove a data with given key

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.remove({ key: 'key-123' });

Clear the Data Store (delete all keys)

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.clear();

Check if a data key exists

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.iskey({ key: 'key-123' });
console.log(result);

Get the data key list

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keys();
console.log(result);

Get the data value list

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.values();
console.log(result);

Get the data value list for filter keys

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.filtervalues({ filter: 'filter' });
console.log(result);

Get the data key/value pair list

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.keysvalues();
console.log(result);

Check if a table exists

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isTable({ table: 'table' });
console.log(result);

Get the table list for the current store

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.tables();
console.log(result);

Delete a table

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
await CapgoCapacitorDataStorageSqlite.deleteTable({ table: 'table' });

Import a database From a JSON

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.importFromJson({ jsonstring: 'jsonstring' });
console.log(result);

Check the validity of a JSON Object

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.isJsonValid({ jsonstring: 'jsonstring' });
console.log(result);

Export the given database to a JSON Object

import { CapgoCapacitorDataStorageSqlite } from '@capgo/capacitor-data-storage-sqlite';
const result = await CapgoCapacitorDataStorageSqlite.exportToJson();
console.log(result);
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
}
export interface capStorageOptions {
/**
* The storage name
*/
database: string;
}
export interface capDataStorageResult {
/**
* result set to true when successful else false
*/
result?: boolean;
/**
* a returned message
*/
message?: string;
}
export interface capTableStorageOptions {
/**
* The storage table name
*/
table: string;
}
export interface capDataStorageOptions {
/**
* The data name
*/
key: string;
/**
* The data value when required
*/
value?: string;
}
export interface capValueResult {
/**
* the data value for a given data key
*/
value: string;
}
export interface capKeysResult {
/**
* the data key list as an Array
*/
keys: string[];
}
export interface capValuesResult {
/**
* the data values list as an Array
*/
values: string[];
}
export interface capFilterStorageOptions {
/**
* The filter data for filtering keys
*
* ['%filter', 'filter', 'filter%'] for
* [starts with filter, contains filter, ends with filter]
*/
filter: string;
}
export interface capKeysValuesResult {
/**
* the data keys/values list as an Array of {key:string,value:string}
*/
keysvalues: any[];
}
export interface capTablesResult {
/**
* the tables list as an Array
*/
tables: string[];
}
export interface capStoreImportOptions {
/**
* Set the JSON object to import
*
*/
jsonstring?: string;
}

This page is generated from the plugin’s src/definitions.ts. Re-run the sync when the public API changes upstream.

If you are using Getting Started to plan storage and file handling, connect it with Using @capgo/capacitor-data-storage-sqlite for the native capability in Using @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-data-storage-sqlite for the implementation detail in @capgo/capacitor-data-storage-sqlite, @capgo/capacitor-file for the implementation detail in @capgo/capacitor-file, Using @capgo/capacitor-file for the native capability in Using @capgo/capacitor-file, and @capgo/capacitor-uploader for the implementation detail in @capgo/capacitor-uploader.