Socket
Socket
Sign inDemoInstall

@capacitor-community/sqlite

Package Overview
Dependencies
Maintainers
29
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-community/sqlite - npm Package Compare versions

Comparing version 3.0.0-beta.4 to 3.0.0-beta.5

android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsMigrate.java

26

CHANGELOG.md

@@ -0,1 +1,27 @@

## 3.0.0-beta.5 (2021-03-18)
### Chore
- Update to Capacitor 3.0.0-rc.0
### Added Features
- isConnection method
- isDatabase method
- getDatabaseList method
- isTable method
- addSQLiteSuffix method
- deleteOldDatabases method
- isDBOpen
- MigratingCordovaDatabases.md
### Bug Fixes
- Fix Copy db from storage issue#77
- Fix Is there a way to connect to a db file, that not has the prefix SQLite.db issue#79
- Fix More precise error message on failing statements issue#82
- Fix issue#84 Android
- Fix executeSet on android not accept null values issue#89
- Fix issue#97
## 3.0.0-beta.4 (2021-02-01)

@@ -2,0 +28,0 @@

113

dist/esm/definitions.d.ts

@@ -75,3 +75,3 @@ declare module '@capacitor/core' {

/**
* Check is a SQLite database exists
* Check if a SQLite database exists with opened connection
* @param options: capSQLiteOptions

@@ -83,2 +83,23 @@ * @returns Promise<capSQLiteResult>

/**
* Check if a SQLite database is opened
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a SQLite database exists without connection
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a table exists in a SQLite database
* @param options: capSQLiteTableOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isTableExists(options: capSQLiteTableOptions): Promise<capSQLiteResult>;
/**
* Delete a SQLite database

@@ -146,2 +167,22 @@ * @param options: capSQLiteOptions

copyFromAssets(): Promise<void>;
/**
* Get the database list
* @returns Promise<capSQLiteValues>
* @since 3.0.0-beta.5
*/
getDatabaseList(): Promise<capSQLiteValues>;
/**
* Add SQLIte Suffix to existing databases
* @param options: capSQLitePathOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
addSQLiteSuffix(options: capSQLitePathOptions): Promise<void>;
/**
* Delete Old Cordova databases
* @param options: capSQLitePathOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>;
}

@@ -278,2 +319,18 @@ export interface capEchoOptions {

}
export interface capSQLitePathOptions {
/**
* The folder path of existing databases
*/
folderPath?: string;
}
export interface capSQLiteTableOptions {
/**
* The database name
*/
database?: string;
/**
* The table name
*/
table?: string;
}
export interface capEchoResult {

@@ -464,2 +521,9 @@ /**

/**
* Check if a connection exists
* @param database
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isConnection(database: string): Promise<capSQLiteResult>;
/**
* Retrieve an existing database connection

@@ -510,2 +574,29 @@ * @param database

copyFromAssets(): Promise<void>;
/**
* Check if a database exists
* @param database
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDatabase(database: string): Promise<capSQLiteResult>;
/**
* Get the database list
* @returns Promise<capSQLiteValues>
* @since 3.0.0-beta.5
*/
getDatabaseList(): Promise<capSQLiteValues>;
/**
* Add SQLIte Suffix to existing databases
* @param folderPath
* @returns Promise<void>
* @since 3.0.0-beta.5
*/
addSQLiteSuffix(folderPath?: string): Promise<void>;
/**
* Delete Old Cordova databases
* @param folderPath
* @returns Promise<void>
* @since 3.0.0-beta.5
*/
deleteOldDatabases(folderPath?: string): Promise<void>;
}

@@ -523,2 +614,3 @@ /**

closeConnection(database: string): Promise<void>;
isConnection(database: string): Promise<capSQLiteResult>;
retrieveConnection(database: string): Promise<SQLiteDBConnection>;

@@ -530,2 +622,6 @@ retrieveAllConnections(): Promise<Map<string, SQLiteDBConnection>>;

copyFromAssets(): Promise<void>;
isDatabase(database: string): Promise<capSQLiteResult>;
getDatabaseList(): Promise<capSQLiteValues>;
addSQLiteSuffix(folderPath?: string): Promise<void>;
deleteOldDatabases(folderPath?: string): Promise<void>;
}

@@ -591,2 +687,15 @@ /**

/**
* Check if a SQLite database is opened
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a table exists
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isTable(table: string): Promise<capSQLiteResult>;
/**
* Delete a SQLite DB Connection

@@ -639,2 +748,4 @@ * @returns Promise<void>

isExists(): Promise<capSQLiteResult>;
isTable(table: string): Promise<capSQLiteResult>;
isDBOpen(): Promise<capSQLiteResult>;
delete(): Promise<void>;

@@ -641,0 +752,0 @@ createSyncTable(): Promise<capSQLiteChanges>;

@@ -56,2 +56,7 @@ /**

}
async isConnection(database) {
const res = {};
res.result = this._connectionDict.has(database);
return res;
}
async retrieveConnection(database) {

@@ -116,2 +121,40 @@ if (this._connectionDict.has(database)) {

}
async isDatabase(database) {
try {
const res = await this.sqlite.isDatabase({ database: database });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async getDatabaseList() {
try {
const res = await this.sqlite.getDatabaseList();
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async addSQLiteSuffix(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.addSQLiteSuffix({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async deleteOldDatabases(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.deleteOldDatabases({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
}

@@ -230,2 +273,25 @@ /**

}
async isTable(table) {
try {
const res = await this.sqlite.isTableExists({
database: this.dbName,
table: table,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async isDBOpen() {
try {
const res = await this.sqlite.isDBOpen({
database: this.dbName,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async delete() {

@@ -232,0 +298,0 @@ try {

import { WebPlugin } from '@capacitor/core';
import type { CapacitorSQLitePlugin, capEchoOptions, capSQLiteOptions, capSQLiteExecuteOptions, capSQLiteSetOptions, capSQLiteRunOptions, capSQLiteQueryOptions, capSQLiteImportOptions, capSQLiteExportOptions, capSQLiteSyncDateOptions, capEchoResult, capSQLiteResult, capSQLiteChanges, capSQLiteValues, capSQLiteJson, capSQLiteUpgradeOptions, capSQLiteSyncDate } from './definitions';
import type { CapacitorSQLitePlugin, capEchoOptions, capSQLiteOptions, capSQLiteExecuteOptions, capSQLiteSetOptions, capSQLiteRunOptions, capSQLiteQueryOptions, capSQLiteImportOptions, capSQLiteExportOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteTableOptions, capSQLitePathOptions, capEchoResult, capSQLiteResult, capSQLiteChanges, capSQLiteValues, capSQLiteJson, capSQLiteSyncDate } from './definitions';
export declare class CapacitorSQLiteWeb extends WebPlugin implements CapacitorSQLitePlugin {

@@ -15,2 +15,5 @@ constructor();

isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
isDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
isTableExists(options: capSQLiteTableOptions): Promise<capSQLiteResult>;
deleteDatabase(options: capSQLiteOptions): Promise<void>;

@@ -25,2 +28,5 @@ isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;

copyFromAssets(): Promise<void>;
getDatabaseList(): Promise<capSQLiteValues>;
addSQLiteSuffix(options: capSQLitePathOptions): Promise<void>;
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>;
}

@@ -49,2 +49,14 @@ import { WebPlugin } from '@capacitor/core';

}
async isDBOpen(options) {
console.log('in Web isDBOpen', options);
throw this.unimplemented('Not implemented on web.');
}
async isDatabase(options) {
console.log('in Web isDatabase', options);
throw this.unimplemented('Not implemented on web.');
}
async isTableExists(options) {
console.log('in Web isTableExists', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteDatabase(options) {

@@ -86,3 +98,14 @@ console.log('deleteDatabase', options);

}
async getDatabaseList() {
throw this.unimplemented('Not implemented on web.');
}
async addSQLiteSuffix(options) {
console.log('addSQLiteSuffix', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteOldDatabases(options) {
console.log('deleteOldDatabases', options);
throw this.unimplemented('Not implemented on web.');
}
}
//# sourceMappingURL=web.js.map

@@ -62,2 +62,7 @@ 'use strict';

}
async isConnection(database) {
const res = {};
res.result = this._connectionDict.has(database);
return res;
}
async retrieveConnection(database) {

@@ -122,2 +127,40 @@ if (this._connectionDict.has(database)) {

}
async isDatabase(database) {
try {
const res = await this.sqlite.isDatabase({ database: database });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async getDatabaseList() {
try {
const res = await this.sqlite.getDatabaseList();
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async addSQLiteSuffix(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.addSQLiteSuffix({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async deleteOldDatabases(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.deleteOldDatabases({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
}

@@ -236,2 +279,25 @@ /**

}
async isTable(table) {
try {
const res = await this.sqlite.isTableExists({
database: this.dbName,
table: table,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async isDBOpen() {
try {
const res = await this.sqlite.isDBOpen({
database: this.dbName,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async delete() {

@@ -350,2 +416,14 @@ try {

}
async isDBOpen(options) {
console.log('in Web isDBOpen', options);
throw this.unimplemented('Not implemented on web.');
}
async isDatabase(options) {
console.log('in Web isDatabase', options);
throw this.unimplemented('Not implemented on web.');
}
async isTableExists(options) {
console.log('in Web isTableExists', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteDatabase(options) {

@@ -387,2 +465,13 @@ console.log('deleteDatabase', options);

}
async getDatabaseList() {
throw this.unimplemented('Not implemented on web.');
}
async addSQLiteSuffix(options) {
console.log('addSQLiteSuffix', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteOldDatabases(options) {
console.log('deleteOldDatabases', options);
throw this.unimplemented('Not implemented on web.');
}
}

@@ -389,0 +478,0 @@

@@ -59,2 +59,7 @@ var capacitorCapacitorSQLite = (function (exports, core) {

}
async isConnection(database) {
const res = {};
res.result = this._connectionDict.has(database);
return res;
}
async retrieveConnection(database) {

@@ -119,2 +124,40 @@ if (this._connectionDict.has(database)) {

}
async isDatabase(database) {
try {
const res = await this.sqlite.isDatabase({ database: database });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async getDatabaseList() {
try {
const res = await this.sqlite.getDatabaseList();
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async addSQLiteSuffix(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.addSQLiteSuffix({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async deleteOldDatabases(folderPath) {
const path = folderPath ? folderPath : 'default';
try {
const res = await this.sqlite.deleteOldDatabases({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
}

@@ -233,2 +276,25 @@ /**

}
async isTable(table) {
try {
const res = await this.sqlite.isTableExists({
database: this.dbName,
table: table,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async isDBOpen() {
try {
const res = await this.sqlite.isDBOpen({
database: this.dbName,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
}
async delete() {

@@ -347,2 +413,14 @@ try {

}
async isDBOpen(options) {
console.log('in Web isDBOpen', options);
throw this.unimplemented('Not implemented on web.');
}
async isDatabase(options) {
console.log('in Web isDatabase', options);
throw this.unimplemented('Not implemented on web.');
}
async isTableExists(options) {
console.log('in Web isTableExists', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteDatabase(options) {

@@ -384,2 +462,13 @@ console.log('deleteDatabase', options);

}
async getDatabaseList() {
throw this.unimplemented('Not implemented on web.');
}
async addSQLiteSuffix(options) {
console.log('addSQLiteSuffix', options);
throw this.unimplemented('Not implemented on web.');
}
async deleteOldDatabases(options) {
console.log('deleteOldDatabases', options);
throw this.unimplemented('Not implemented on web.');
}
}

@@ -386,0 +475,0 @@

@@ -48,2 +48,8 @@ import type { capSQLiteVersionUpgrade, JsonSQLite } from '../definitions';

/**
* IsTableExists
* @param tableName
* @returns
*/
isTableExists(tableName: string): Promise<boolean>;
/**
* CreateSyncTable

@@ -50,0 +56,0 @@ * create the synchronization table

@@ -157,2 +157,25 @@ import { __awaiter } from "tslib";

/**
* IsTableExists
* @param tableName
* @returns
*/
isTableExists(tableName) {
return __awaiter(this, void 0, void 0, function* () {
if (!this._isDBOpen) {
let msg = `isTableExists: Database ${this._dbName} `;
msg += `not opened`;
return Promise.reject(new Error(msg));
}
const isOpen = this._isDBOpen;
try {
const retB = yield this._uJson.isTableExists(this._mDB, isOpen, tableName);
return Promise.resolve(retB);
}
catch (err) {
const msg = `IsTableExists: ${err.message}`;
return Promise.reject(new Error(msg));
}
});
}
/**
* CreateSyncTable

@@ -159,0 +182,0 @@ * create the synchronization table

2

electron/dist/esm/electron/src/electron-utils/ImportExportJson/utilsJson.js

@@ -150,3 +150,3 @@ import { __awaiter } from "tslib";

let stmt = `CREATE TRIGGER IF NOT EXISTS `;
stmt += `${jTrg.name} ${jTrg.timeevent} ON ${tableName} `;
stmt += `${jTrg.name} ${jTrg.timeevent} ${tableName} `;
if (jTrg.condition)

@@ -153,0 +153,0 @@ stmt += `${jTrg.condition} `;

@@ -28,2 +28,12 @@ export declare class UtilsFile {

/**
* GetCustomerPath
* get the customer path
*/
getCustomerPath(custPath: string): string;
/**
* GetCustomerFilePath
* get the customer file path
*/
getCustomerFilePath(custPath: string, file: string): string;
/**
* GetDatabasesPath

@@ -69,2 +79,3 @@ * get the database folder path

copyFilePath(filePath: string, toFilePath: string): Promise<void>;
copyFile(fromPath: string, fromFile: string, toPath: string, toFile: string): Promise<void>;
/**

@@ -71,0 +82,0 @@ * DeleteFileName

@@ -63,2 +63,16 @@ import { __awaiter } from "tslib";

/**
* GetCustomerPath
* get the customer path
*/
getCustomerPath(custPath) {
return this.Path.join(this.HomeDir, custPath);
}
/**
* GetCustomerFilePath
* get the customer file path
*/
getCustomerFilePath(custPath, file) {
return this.Path.join(custPath, file);
}
/**
* GetDatabasesPath

@@ -211,2 +225,15 @@ * get the database folder path

}
copyFile(fromPath, fromFile, toPath, toFile) {
return __awaiter(this, void 0, void 0, function* () {
const fPath = this.Path.join(fromPath, fromFile);
const tPath = this.Path.join(toPath, toFile);
try {
this.NodeFs.copyFileSync(fPath, tPath);
return Promise.resolve();
}
catch (err) {
return Promise.reject(new Error(`CopyFile: ${err.message}`));
}
});
}
/**

@@ -213,0 +240,0 @@ * DeleteFileName

import { WebPlugin } from '@capacitor/core';
import type { CapacitorSQLitePlugin, capConnectionOptions, capEchoOptions, capEchoResult, capSQLiteChanges, capSQLiteExecuteOptions, capSQLiteExportOptions, capSQLiteImportOptions, capSQLiteJson, capSQLiteOptions, capSQLiteQueryOptions, capSQLiteResult, capSQLiteRunOptions, capSQLiteSetOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteValues, capSQLiteSyncDate } from './definitions';
import type { CapacitorSQLitePlugin, capConnectionOptions, capEchoOptions, capEchoResult, capSQLiteChanges, capSQLiteExecuteOptions, capSQLiteExportOptions, capSQLiteImportOptions, capSQLiteJson, capSQLiteOptions, capSQLiteQueryOptions, capSQLiteResult, capSQLiteRunOptions, capSQLiteSetOptions, capSQLiteSyncDateOptions, capSQLiteUpgradeOptions, capSQLiteValues, capSQLiteSyncDate, capSQLiteTableOptions, capSQLitePathOptions } from './definitions';
export declare class CapacitorSQLiteElectronWeb extends WebPlugin implements CapacitorSQLitePlugin {

@@ -8,2 +8,3 @@ RemoteRef: any;

private _uJson;
private _uMigrate;
private _osType;

@@ -22,2 +23,8 @@ private _versionUpgrades;

isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
isDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
isTableExists(options: capSQLiteTableOptions): Promise<capSQLiteResult>;
getDatabaseList(): Promise<capSQLiteValues>;
addSQLiteSuffix(options: capSQLitePathOptions): Promise<void>;
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>;
deleteDatabase(options: capSQLiteOptions): Promise<void>;

@@ -24,0 +31,0 @@ isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;

@@ -6,2 +6,3 @@ import { __awaiter } from "tslib";

import { UtilsFile } from './electron-utils/utilsFile';
import { UtilsMigrate } from './electron-utils/utilsMigrate';
// eslint-disable-next-line @typescript-eslint/no-var-requires

@@ -19,2 +20,3 @@ const { remote } = require('electron');

this._uJson = new UtilsJson();
this._uMigrate = new UtilsMigrate();
this._versionUpgrades = {};

@@ -271,2 +273,100 @@ console.log('CapacitorSQLite Electron');

}
isDBOpen(options) {
return __awaiter(this, void 0, void 0, function* () {
let keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName = options.database;
keys = Object.keys(this._dbDict);
if (!keys.includes(dbName)) {
return Promise.reject('isDBOpen command failed: No available ' + 'connection for ' + dbName);
}
const mDB = this._dbDict[dbName];
const isOpen = yield mDB.isDBOpen();
return Promise.resolve({ result: isOpen });
});
}
isDatabase(options) {
return __awaiter(this, void 0, void 0, function* () {
const keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName = options.database;
const isExists = this._uFile.isFileExists(dbName + 'SQLite.db');
return Promise.resolve({
result: isExists,
});
});
}
isTableExists(options) {
return __awaiter(this, void 0, void 0, function* () {
let keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName = options.database;
if (!keys.includes('table')) {
return Promise.reject('Must provide a table name');
}
const tableName = options.table;
keys = Object.keys(this._dbDict);
if (!keys.includes(dbName)) {
return Promise.reject('isTableExists command failed: No available ' +
'connection for ' +
dbName);
}
const mDB = this._dbDict[dbName];
try {
const res = yield mDB.isTableExists(tableName);
return Promise.resolve({ result: res.result });
}
catch (err) {
return Promise.reject(`isTableExists: ${err.message}`);
}
});
}
getDatabaseList() {
return __awaiter(this, void 0, void 0, function* () {
// get the database folder
const pathDatabase = this._uFile.getDatabasesPath();
// get the list of databases
const files = yield this._uFile.getFileList(pathDatabase);
if (files.length > 0) {
return Promise.resolve({ values: files });
}
else {
return Promise.reject(`isTableExists: No databases found`);
}
});
}
addSQLiteSuffix(options) {
return __awaiter(this, void 0, void 0, function* () {
const folderPath = options.folderPath
? options.folderPath
: 'default';
try {
yield this._uMigrate.addSQLiteSuffix(folderPath);
return Promise.resolve();
}
catch (err) {
return Promise.reject(`addSQLiteSuffix: ${err.message}`);
}
});
}
deleteOldDatabases(options) {
return __awaiter(this, void 0, void 0, function* () {
const folderPath = options.folderPath
? options.folderPath
: 'default';
try {
yield this._uMigrate.deleteOldDatabases(folderPath);
return Promise.resolve();
}
catch (err) {
return Promise.reject(`deleteOldDatabases: ${err.message}`);
}
});
}
deleteDatabase(options) {

@@ -273,0 +373,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -75,3 +75,3 @@ declare module '@capacitor/core' {

/**
* Check is a SQLite database exists
* Check if a SQLite database exists with opened connection
* @param options: capSQLiteOptions

@@ -83,2 +83,23 @@ * @returns Promise<capSQLiteResult>

/**
* Check if a SQLite database is opened
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a SQLite database exists without connection
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a table exists in a SQLite database
* @param options: capSQLiteTableOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isTableExists(options: capSQLiteTableOptions): Promise<capSQLiteResult>;
/**
* Delete a SQLite database

@@ -146,2 +167,22 @@ * @param options: capSQLiteOptions

copyFromAssets(): Promise<void>;
/**
* Get the database list
* @returns Promise<capSQLiteValues>
* @since 3.0.0-beta.5
*/
getDatabaseList(): Promise<capSQLiteValues>;
/**
* Add SQLIte Suffix to existing databases
* @param options: capSQLitePathOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
addSQLiteSuffix(options: capSQLitePathOptions): Promise<void>;
/**
* Delete Old Cordova databases
* @param options: capSQLitePathOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
deleteOldDatabases(options: capSQLitePathOptions): Promise<void>;
}

@@ -278,2 +319,18 @@ export interface capEchoOptions {

}
export interface capSQLitePathOptions {
/**
* The folder path of existing databases
*/
folderPath?: string;
}
export interface capSQLiteTableOptions {
/**
* The database name
*/
database?: string;
/**
* The table name
*/
table?: string;
}
export interface capEchoResult {

@@ -464,2 +521,9 @@ /**

/**
* Check if a connection exists
* @param database
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isConnection(database: string): Promise<capSQLiteResult>;
/**
* Retrieve an existing database connection

@@ -510,2 +574,29 @@ * @param database

copyFromAssets(): Promise<void>;
/**
* Check if a database exists
* @param database
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDatabase(database: string): Promise<capSQLiteResult>;
/**
* Get the database list
* @returns Promise<capSQLiteValues>
* @since 3.0.0-beta.5
*/
getDatabaseList(): Promise<capSQLiteValues>;
/**
* Add SQLIte Suffix to existing databases
* @param folderPath
* @returns Promise<void>
* @since 3.0.0-beta.5
*/
addSQLiteSuffix(folderPath?: string): Promise<void>;
/**
* Delete Old Cordova databases
* @param folderPath
* @returns Promise<void>
* @since 3.0.0-beta.5
*/
deleteOldDatabases(folderPath?: string): Promise<void>;
}

@@ -523,2 +614,3 @@ /**

closeConnection(database: string): Promise<void>;
isConnection(database: string): Promise<capSQLiteResult>;
retrieveConnection(database: string): Promise<SQLiteDBConnection>;

@@ -530,2 +622,6 @@ retrieveAllConnections(): Promise<Map<string, SQLiteDBConnection>>;

copyFromAssets(): Promise<void>;
isDatabase(database: string): Promise<capSQLiteResult>;
getDatabaseList(): Promise<capSQLiteValues>;
addSQLiteSuffix(folderPath?: string): Promise<void>;
deleteOldDatabases(folderPath?: string): Promise<void>;
}

@@ -591,2 +687,15 @@ /**

/**
* Check if a SQLite database is opened
* @param options: capSQLiteOptions
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult>;
/**
* Check if a table exists
* @returns Promise<capSQLiteResult>
* @since 3.0.0-beta.5
*/
isTable(table: string): Promise<capSQLiteResult>;
/**
* Delete a SQLite DB Connection

@@ -639,2 +748,4 @@ * @returns Promise<void>

isExists(): Promise<capSQLiteResult>;
isTable(table: string): Promise<capSQLiteResult>;
isDBOpen(): Promise<capSQLiteResult>;
delete(): Promise<void>;

@@ -641,0 +752,0 @@ createSyncTable(): Promise<capSQLiteChanges>;

@@ -65,2 +65,9 @@ import { __awaiter } from "tslib";

}
isConnection(database) {
return __awaiter(this, void 0, void 0, function* () {
const res = {};
res.result = this._connectionDict.has(database);
return res;
});
}
retrieveConnection(database) {

@@ -137,2 +144,48 @@ return __awaiter(this, void 0, void 0, function* () {

}
isDatabase(database) {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield this.sqlite.isDatabase({ database: database });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
getDatabaseList() {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield this.sqlite.getDatabaseList();
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
addSQLiteSuffix(folderPath) {
return __awaiter(this, void 0, void 0, function* () {
const path = folderPath ? folderPath : 'default';
try {
const res = yield this.sqlite.addSQLiteSuffix({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
deleteOldDatabases(folderPath) {
return __awaiter(this, void 0, void 0, function* () {
const path = folderPath ? folderPath : 'default';
try {
const res = yield this.sqlite.deleteOldDatabases({ folderPath: path });
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
}

@@ -265,2 +318,29 @@ /**

}
isTable(table) {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield this.sqlite.isTableExists({
database: this.dbName,
table: table,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
isDBOpen() {
return __awaiter(this, void 0, void 0, function* () {
try {
const res = yield this.sqlite.isDBOpen({
database: this.dbName,
});
return Promise.resolve(res);
}
catch (err) {
return Promise.reject(err);
}
});
}
delete() {

@@ -267,0 +347,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -175,2 +175,26 @@ import { GlobalSQLite } from '../GlobalSQLite';

/**
* IsTableExists
* @param tableName
* @returns
*/
async isTableExists(tableName: string): Promise<boolean> {
if (!this._isDBOpen) {
let msg = `isTableExists: Database ${this._dbName} `;
msg += `not opened`;
return Promise.reject(new Error(msg));
}
const isOpen: boolean = this._isDBOpen;
try {
const retB = await this._uJson.isTableExists(
this._mDB,
isOpen,
tableName,
);
return Promise.resolve(retB);
} catch (err) {
const msg = `IsTableExists: ${err.message}`;
return Promise.reject(new Error(msg));
}
}
/**
* CreateSyncTable

@@ -177,0 +201,0 @@ * create the synchronization table

@@ -158,3 +158,3 @@ import type { JsonColumn, JsonIndex, JsonTrigger } from '../../definitions';

let stmt = `CREATE TRIGGER IF NOT EXISTS `;
stmt += `${jTrg.name} ${jTrg.timeevent} ON ${tableName} `;
stmt += `${jTrg.name} ${jTrg.timeevent} ${tableName} `;
if (jTrg.condition) stmt += `${jTrg.condition} `;

@@ -161,0 +161,0 @@ stmt += `${jTrg.logic};`;

@@ -68,2 +68,16 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires

/**
* GetCustomerPath
* get the customer path
*/
public getCustomerPath(custPath: string): string {
return this.Path.join(this.HomeDir, custPath);
}
/**
* GetCustomerFilePath
* get the customer file path
*/
public getCustomerFilePath(custPath: string, file: string): string {
return this.Path.join(custPath, file);
}
/**
* GetDatabasesPath

@@ -220,2 +234,17 @@ * get the database folder path

}
public async copyFile(
fromPath: string,
fromFile: string,
toPath: string,
toFile: string,
): Promise<void> {
const fPath: string = this.Path.join(fromPath, fromFile);
const tPath: string = this.Path.join(toPath, toFile);
try {
this.NodeFs.copyFileSync(fPath, tPath);
return Promise.resolve();
} catch (err) {
return Promise.reject(new Error(`CopyFile: ${err.message}`));
}
}
/**

@@ -222,0 +251,0 @@ * DeleteFileName

@@ -23,2 +23,4 @@ import { WebPlugin } from '@capacitor/core';

capSQLiteSyncDate,
capSQLiteTableOptions,
capSQLitePathOptions,
JsonSQLite,

@@ -29,2 +31,3 @@ } from './definitions';

import { UtilsFile } from './electron-utils/utilsFile';
import { UtilsMigrate } from './electron-utils/utilsMigrate';

@@ -41,2 +44,3 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires

private _uJson: UtilsJson = new UtilsJson();
private _uMigrate: UtilsMigrate = new UtilsMigrate();
private _osType: string;

@@ -297,2 +301,94 @@ private _versionUpgrades: Record<

}
async isDBOpen(options: capSQLiteOptions): Promise<capSQLiteResult> {
let keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName: string = options.database;
keys = Object.keys(this._dbDict);
if (!keys.includes(dbName)) {
return Promise.reject(
'isDBOpen command failed: No available ' + 'connection for ' + dbName,
);
}
const mDB = this._dbDict[dbName];
const isOpen: boolean = await mDB.isDBOpen();
return Promise.resolve({ result: isOpen });
}
async isDatabase(options: capSQLiteOptions): Promise<capSQLiteResult> {
const keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName: string = options.database;
const isExists: boolean = this._uFile.isFileExists(dbName + 'SQLite.db');
return Promise.resolve({
result: isExists,
});
}
async isTableExists(
options: capSQLiteTableOptions,
): Promise<capSQLiteResult> {
let keys = Object.keys(options);
if (!keys.includes('database')) {
return Promise.reject('Must provide a database name');
}
const dbName: string = options.database;
if (!keys.includes('table')) {
return Promise.reject('Must provide a table name');
}
const tableName: string = options.table;
keys = Object.keys(this._dbDict);
if (!keys.includes(dbName)) {
return Promise.reject(
'isTableExists command failed: No available ' +
'connection for ' +
dbName,
);
}
const mDB = this._dbDict[dbName];
try {
const res: any = await mDB.isTableExists(tableName);
return Promise.resolve({ result: res.result });
} catch (err) {
return Promise.reject(`isTableExists: ${err.message}`);
}
}
async getDatabaseList(): Promise<capSQLiteValues> {
// get the database folder
const pathDatabase = this._uFile.getDatabasesPath();
// get the list of databases
const files: string[] = await this._uFile.getFileList(pathDatabase);
if (files.length > 0) {
return Promise.resolve({ values: files });
} else {
return Promise.reject(`isTableExists: No databases found`);
}
}
async addSQLiteSuffix(options: capSQLitePathOptions): Promise<void> {
const folderPath: string = options.folderPath
? options.folderPath
: 'default';
try {
await this._uMigrate.addSQLiteSuffix(folderPath);
return Promise.resolve();
} catch (err) {
return Promise.reject(`addSQLiteSuffix: ${err.message}`);
}
}
async deleteOldDatabases(options: capSQLitePathOptions): Promise<void> {
const folderPath: string = options.folderPath
? options.folderPath
: 'default';
try {
await this._uMigrate.deleteOldDatabases(folderPath);
return Promise.resolve();
} catch (err) {
return Promise.reject(`deleteOldDatabases: ${err.message}`);
}
}
async deleteDatabase(options: capSQLiteOptions): Promise<void> {

@@ -299,0 +395,0 @@ let keys = Object.keys(options);

{
"name": "@capacitor-community/sqlite",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"description": "Community plugin for native & electron SQLite databases",

@@ -51,2 +51,3 @@ "main": "dist/plugin.cjs.js",

"watch": "tsc --watch",
"test": "echo \"No test specified\"",
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"

@@ -53,0 +54,0 @@ },

@@ -169,2 +169,3 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>

| closeConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| isConnection | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| open (non-encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ |

@@ -187,2 +188,8 @@ | open (encrypted DB) | ✅ | ✅ | 🚧 | 🚧 | ❌ |

| copyFromAssets | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| isDBOpen | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| isDatabase | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| isTableExists | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| getDatabaseList | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| addSQLiteSuffix | ✅ | ✅ | 🚧 | 🚧 | ❌ |
| deleteOldDatabases | ✅ | ✅ | 🚧 | 🚧 | ❌ |

@@ -203,2 +210,4 @@ ## Documentation

- [MigratingCordovaDatabases_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/MigratingCordovaDatabases.md)
### Framework's Usage

@@ -205,0 +214,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc