Socket
Socket
Sign inDemoInstall

@capacitor-community/sqlite

Package Overview
Dependencies
Maintainers
14
Versions
241
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 2.4.2-2 to 2.4.2-3

android/.gradle/5.6.4/executionHistory/executionHistory.bin

18

CHANGELOG.md

@@ -0,1 +1,19 @@

## 2.4.2-3 (2020-10-06)
### ### Added Features
- Add docgen to generate API documentation
- Add a trigger for last_modified in importFromJson method to update the last-modified field when a data in an another field is updated
### Bug Fixes
- Split up capSQLiteOptions capSQLiteResult in multiple interfaces issue#4
## 2.4.2-2 (2020-09-29)
### Bug Fixes
- Fix podspec file name (iOS)
## 2.4.2-1 (2020-09-29)

@@ -2,0 +20,0 @@

251

dist/esm/definitions.d.ts

@@ -7,11 +7,15 @@ declare module '@capacitor/core' {

export interface CapacitorSQLitePlugin {
echo(options: {
value: string;
}): Promise<{
value: string;
}>;
/**
* Echo a given string
*
* @param options The echo options
* @return Promise<{ value: string }
* @since 0.0.1
*/
echo(options: capEchoOptions): Promise<capEchoResult>;
/**
* Open a SQLite database
* @param {capSQLiteOptions} options {database: string, encrypted?: boolean, mode?: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -21,4 +25,5 @@ open(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Close a SQLite database
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -28,28 +33,33 @@ close(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Execute a Batch of Raw Statements as String
* @param {capSQLiteOptions} options {statements: string}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteExecuteOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 0.0.1
*/
execute(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>;
/**
* Execute a Set of Raw Statements as Array of CapSQLiteSet
* @param {capSQLiteOptions} options {set: Array<CapSQLiteSet>}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteSetOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 2.2.0-2
*/
executeSet(options: capSQLiteOptions): Promise<capSQLiteResult>;
executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges>;
/**
* Execute a Single Statement
* @param {capSQLiteOptions} options {statement: string, values:Array<any> }
* @returns {Promise<capSQLiteResult>} {changes:{changes:number,lastId:number}}
* @param {capSQLiteRunOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 0.0.1
*/
run(options: capSQLiteOptions): Promise<capSQLiteResult>;
run(options: capSQLiteRunOptions): Promise<capSQLiteChanges>;
/**
* Query a Single Statement
* @param {capSQLiteOptions} options {statement: string, values:Array<string> }
* @returns {Promise<capSQLiteResult>} {values:Array<any>}
* @param {capSQLiteQueryOptions} options
* @returns {Promise<capSQLiteValues>}
* @since 0.0.1
*/
query(options: capSQLiteOptions): Promise<capSQLiteResult>;
query(options: capSQLiteQueryOptions): Promise<capSQLiteValues>;
/**
* Check is a SQLite database exists
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/

@@ -59,4 +69,5 @@ isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Delete a SQLite database
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -66,30 +77,41 @@ deleteDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Is Json Object Valid
* @param {capSQLiteOptions} options {jsonstring: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteImportOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/
isJsonValid(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;
/**
* Import from Json Object
* @param {capSQLiteOptions} options {jsonstring: string}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteImportOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 2.0.0-3
*/
importFromJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteImportOptions): Promise<capSQLiteChanges>;
/**
* Export to Json Object
* @param {capSQLiteOptions} options {jsonexportmode: string}
* @returns {Promise<capSQLiteResult>} {export:any}
* @param {capSQLiteExportOptions} options
* @returns {Promise<capSQLiteJson>}
* @since 2.0.1-1
*/
exportToJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
exportToJson(options: capSQLiteExportOptions): Promise<capSQLiteJson>;
/**
* Create a synchronization table
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @returns {Promise<capSQLiteChanges>}
* @since 2.0.1-1
*/
createSyncTable(): Promise<capSQLiteResult>;
createSyncTable(): Promise<capSQLiteChanges>;
/**
* Set the synchronization date
* @param {capSQLiteOptions} options {syncdate: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteSyncDateOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>;
setSyncDate(options: capSQLiteSyncDateOptions): Promise<capSQLiteResult>;
}
export interface capEchoOptions {
/**
* String to be echoed
*/
value?: string;
}
export interface capSQLiteOptions {

@@ -101,9 +123,26 @@ /**

/**
* Set to true (database encryption) / false
* - Open method only
*/
encrypted?: boolean;
/**
* Set the mode for database encryption
* ["encryption", "secret", "newsecret"]
* - Open method only
*/
mode?: string;
}
export interface capSQLiteExecuteOptions {
/**
* The batch of raw SQL statements as string
*/
statements?: string;
}
export interface capSQLiteSetOptions {
/**
* The batch of raw SQL statements as Array of capSQLLiteSet
*/
set?: Array<capSQLiteSet>;
set?: capSQLiteSet[];
}
export interface capSQLiteRunOptions {
/**

@@ -116,13 +155,16 @@ * A statement

*/
values?: Array<any>;
values?: any[];
}
export interface capSQLiteQueryOptions {
/**
* Set to true for database encryption
* A statement
*/
encrypted?: boolean;
/***
* Set the mode for database encryption
* ["encryption", "secret","newsecret"]
statement?: string;
/**
* A set of values for a statement
*/
mode?: string;
/***
values?: string[];
}
export interface capSQLiteImportOptions {
/**
* Set the JSON object to import

@@ -132,9 +174,13 @@ *

jsonstring?: string;
/***
* Set the mode to export JSON Object
* "full", "partial"
}
export interface capSQLiteExportOptions {
/**
* Set the mode to export JSON Object:
* "full" or "partial"
*
*/
jsonexportmode?: string;
/***
}
export interface capSQLiteSyncDateOptions {
/**
* Set the synchronization date

@@ -145,2 +191,18 @@ *

}
export interface capSQLiteSet {
/**
* A statement
*/
statement?: string;
/**
* the data values list as an Array
*/
values?: any[];
}
export interface capEchoResult {
/**
* String returned
*/
value?: string;
}
export interface capSQLiteResult {

@@ -152,2 +214,8 @@ /**

/**
* a returned message
*/
message?: string;
}
export interface capSQLiteChanges {
/**
* the number of changes from an execute or run command

@@ -157,23 +225,86 @@ */

/**
* a returned message
*/
message?: string;
}
export interface capSQLiteValues {
/**
* the data values list as an Array
*/
values?: Array<any>;
values?: any[];
/**
* a message
* a returned message
*/
message?: string;
}
export interface capSQLiteJson {
/**
* an export JSON object
*/
export?: any;
export?: JsonSQLite;
/**
* a returned message
*/
message?: string;
}
export interface capSQLiteSet {
export interface JsonSQLite {
/**
* A statement
* The database name
*/
statement?: String;
database: string;
/**
* the data values list as an Array
* Set to true (database encryption) / false
*/
values?: Array<any>;
encrypted: boolean;
/***
* Set the mode
* ["full", "partial"]
*/
mode: string;
/***
* Array of Table (JsonTable)
*/
tables: JsonTable[];
}
export interface JsonTable {
/**
* The database name
*/
name: string;
/***
* Array of Schema (JsonColumn)
*/
schema?: JsonColumn[];
/***
* Array of Index (JsonIndex)
*/
indexes?: JsonIndex[];
/***
* Array of Table data
*/
values?: any[][];
}
export interface JsonColumn {
/**
* The column name
*/
column?: string;
/**
* The column data (type, unique, ...)
*/
value: string;
/**
* The column foreign key constraints
*/
foreignkey?: string;
}
export interface JsonIndex {
/**
* The index name
*/
name: string;
/**
* The column name to be indexed
*/
column: string;
}
import { WebPlugin } from '@capacitor/core';
import { CapacitorSQLitePlugin, capSQLiteOptions, capSQLiteResult } from './definitions';
import { CapacitorSQLitePlugin, capEchoOptions, capSQLiteOptions, capSQLiteExecuteOptions, capSQLiteSetOptions, capSQLiteRunOptions, capSQLiteQueryOptions, capSQLiteImportOptions, capSQLiteExportOptions, capSQLiteSyncDateOptions, capEchoResult, capSQLiteResult, capSQLiteChanges, capSQLiteValues, capSQLiteJson } from './definitions';
export declare class CapacitorSQLiteWeb extends WebPlugin implements CapacitorSQLitePlugin {
constructor();
echo(options: {
value: string;
}): Promise<{
value: string;
}>;
echo(options: capEchoOptions): Promise<capEchoResult>;
open(options: capSQLiteOptions): Promise<capSQLiteResult>;
close(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteOptions): Promise<capSQLiteResult>;
executeSet(options: capSQLiteOptions): Promise<capSQLiteResult>;
run(options: capSQLiteOptions): Promise<capSQLiteResult>;
query(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>;
executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges>;
run(options: capSQLiteRunOptions): Promise<capSQLiteChanges>;
query(options: capSQLiteQueryOptions): Promise<capSQLiteValues>;
isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;
deleteDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
exportToJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
createSyncTable(): Promise<capSQLiteResult>;
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteImportOptions): Promise<capSQLiteChanges>;
exportToJson(options: capSQLiteExportOptions): Promise<capSQLiteJson>;
createSyncTable(): Promise<capSQLiteChanges>;
setSyncDate(options: capSQLiteSyncDateOptions): Promise<capSQLiteResult>;
}
declare const CapacitorSQLite: CapacitorSQLiteWeb;
export { CapacitorSQLite };

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

export * from "../../src/definitions";
export * from '../../src/definitions';

@@ -1,2 +0,2 @@

export * from "../../src/definitions";
export * from '../../src/definitions';
//# sourceMappingURL=definitions.js.map

@@ -1,2 +0,2 @@

import { JsonSQLite } from './JsonUtils';
import { JsonSQLite } from '../definitions';
export declare class DatabaseSQLiteHelper {

@@ -3,0 +3,0 @@ isOpen: boolean;

import { __awaiter } from "tslib";
import { UtilsSQLite } from './UtilsSQLite';
import { isJsonSQLite, isTable, } from './JsonUtils';
import { isJsonSQLite, isTable } from './JsonUtils';
export class DatabaseSQLiteHelper {

@@ -361,2 +361,3 @@ constructor(dbName /*, encrypted:boolean = false, mode:string = "no-encryption",

statements.push(`DROP TABLE IF EXISTS ${jsonData.tables[i].name};`);
// create table
statements.push(`CREATE TABLE IF NOT EXISTS ${jsonData.tables[i].name} (`);

@@ -382,2 +383,4 @@ for (let j = 0; j < jsonData.tables[i].schema.length; j++) {

statements.push(');');
// create trigger last_modified associated with the table
statements.push(`CREATE TRIGGER IF NOT EXISTS ${jsonData.tables[i].name}_trigger_last_modified AFTER UPDATE ON ${jsonData.tables[i].name} FOR EACH ROW WHEN NEW.last_modified <= OLD.last_modified BEGIN UPDATE ${jsonData.tables[i].name} SET last_modified = (strftime('%s','now')) WHERE id=OLD.id; END;`);
}

@@ -384,0 +387,0 @@ if (jsonData.tables[i].indexes != null &&

@@ -1,23 +0,2 @@

export declare type JsonSQLite = {
database: string;
encrypted: boolean;
mode: string;
tables: Array<JsonTable>;
};
export declare type JsonTable = {
name: string;
schema?: Array<JsonColumn>;
indexes?: Array<JsonIndex>;
values?: Array<Array<any>>;
};
export declare type JsonColumn = {
column?: string;
value: string;
foreignkey?: string;
};
export declare type JsonIndex = {
name: string;
column: string;
};
export declare function isJsonSQLite(obj: any): boolean;
export declare function isTable(obj: any): boolean;

@@ -1,2 +0,2 @@

export * from "./definitions";
export * from "./plugin";
export * from './definitions';
export * from './plugin';

@@ -1,3 +0,3 @@

export * from "./definitions";
export * from "./plugin";
export * from './definitions';
export * from './plugin';
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

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

@@ -8,22 +8,18 @@ NodeFs: any;

constructor();
echo(options: {
value: string;
}): Promise<{
value: string;
}>;
echo(options: capEchoOptions): Promise<capEchoResult>;
open(options: capSQLiteOptions): Promise<capSQLiteResult>;
close(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteOptions): Promise<capSQLiteResult>;
executeSet(options: capSQLiteOptions): Promise<capSQLiteResult>;
run(options: capSQLiteOptions): Promise<capSQLiteResult>;
query(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>;
executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges>;
run(options: capSQLiteRunOptions): Promise<capSQLiteChanges>;
query(options: capSQLiteQueryOptions): Promise<capSQLiteValues>;
isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;
deleteDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
exportToJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
createSyncTable(): Promise<capSQLiteResult>;
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteImportOptions): Promise<capSQLiteChanges>;
exportToJson(options: capSQLiteExportOptions): Promise<capSQLiteJson>;
createSyncTable(): Promise<capSQLiteChanges>;
setSyncDate(options: capSQLiteSyncDateOptions): Promise<capSQLiteResult>;
}
declare const CapacitorSQLite: CapacitorSQLiteElectronWeb;
export { CapacitorSQLite };
import { __awaiter } from "tslib";
import { WebPlugin } from "@capacitor/core";
import { WebPlugin } from '@capacitor/core';
import { DatabaseSQLiteHelper } from './electron-utils/DatabaseSQLiteHelper';
import { isJsonSQLite } from './electron-utils/JsonUtils';
import { UtilsSQLite } from './electron-utils/UtilsSQLite';
const { remote } = require("electron");
const { remote } = require('electron');
export class CapacitorSQLiteElectronWeb extends WebPlugin {

@@ -15,9 +15,9 @@ constructor() {

this.RemoteRef = null;
console.log("CapacitorSQLite Electron");
console.log('CapacitorSQLite Electron');
this.RemoteRef = remote;
this.NodeFs = require("fs");
this.NodeFs = require('fs');
}
echo(options) {
return __awaiter(this, void 0, void 0, function* () {
console.log("ECHO in CapacitorSQLiteElectronWeb ", options);
console.log('ECHO in CapacitorSQLiteElectronWeb ', options);
console.log(this.RemoteRef);

@@ -142,3 +142,3 @@ return options;

return Promise.reject({
changes: -1,
values: [],
message: 'Query command failed : Must provide a SQL statement',

@@ -149,3 +149,3 @@ });

return Promise.reject({
changes: -1,
values: [],
message: 'Query command failed : Values should be an Array of values',

@@ -315,4 +315,4 @@ });

export { CapacitorSQLite };
import { registerWebPlugin } from "@capacitor/core";
import { registerWebPlugin } from '@capacitor/core';
registerWebPlugin(CapacitorSQLite);
//# sourceMappingURL=plugin.js.map

@@ -7,11 +7,15 @@ declare module '@capacitor/core' {

export interface CapacitorSQLitePlugin {
echo(options: {
value: string;
}): Promise<{
value: string;
}>;
/**
* Echo a given string
*
* @param options The echo options
* @return Promise<{ value: string }
* @since 0.0.1
*/
echo(options: capEchoOptions): Promise<capEchoResult>;
/**
* Open a SQLite database
* @param {capSQLiteOptions} options {database: string, encrypted?: boolean, mode?: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -21,4 +25,5 @@ open(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Close a SQLite database
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -28,28 +33,33 @@ close(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Execute a Batch of Raw Statements as String
* @param {capSQLiteOptions} options {statements: string}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteExecuteOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 0.0.1
*/
execute(options: capSQLiteOptions): Promise<capSQLiteResult>;
execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges>;
/**
* Execute a Set of Raw Statements as Array of CapSQLiteSet
* @param {capSQLiteOptions} options {set: Array<CapSQLiteSet>}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteSetOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 2.2.0-2
*/
executeSet(options: capSQLiteOptions): Promise<capSQLiteResult>;
executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges>;
/**
* Execute a Single Statement
* @param {capSQLiteOptions} options {statement: string, values:Array<any> }
* @returns {Promise<capSQLiteResult>} {changes:{changes:number,lastId:number}}
* @param {capSQLiteRunOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 0.0.1
*/
run(options: capSQLiteOptions): Promise<capSQLiteResult>;
run(options: capSQLiteRunOptions): Promise<capSQLiteChanges>;
/**
* Query a Single Statement
* @param {capSQLiteOptions} options {statement: string, values:Array<string> }
* @returns {Promise<capSQLiteResult>} {values:Array<any>}
* @param {capSQLiteQueryOptions} options
* @returns {Promise<capSQLiteValues>}
* @since 0.0.1
*/
query(options: capSQLiteOptions): Promise<capSQLiteResult>;
query(options: capSQLiteQueryOptions): Promise<capSQLiteValues>;
/**
* Check is a SQLite database exists
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/

@@ -59,4 +69,5 @@ isDBExists(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Delete a SQLite database
* @param {capSQLiteOptions} options {database: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 0.0.1
*/

@@ -66,30 +77,41 @@ deleteDatabase(options: capSQLiteOptions): Promise<capSQLiteResult>;

* Is Json Object Valid
* @param {capSQLiteOptions} options {jsonstring: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteImportOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/
isJsonValid(options: capSQLiteOptions): Promise<capSQLiteResult>;
isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult>;
/**
* Import from Json Object
* @param {capSQLiteOptions} options {jsonstring: string}
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @param {capSQLiteImportOptions} options
* @returns {Promise<capSQLiteChanges>}
* @since 2.0.0-3
*/
importFromJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
importFromJson(options: capSQLiteImportOptions): Promise<capSQLiteChanges>;
/**
* Export to Json Object
* @param {capSQLiteOptions} options {jsonexportmode: string}
* @returns {Promise<capSQLiteResult>} {export:any}
* @param {capSQLiteExportOptions} options
* @returns {Promise<capSQLiteJson>}
* @since 2.0.1-1
*/
exportToJson(options: capSQLiteOptions): Promise<capSQLiteResult>;
exportToJson(options: capSQLiteExportOptions): Promise<capSQLiteJson>;
/**
* Create a synchronization table
* @returns {Promise<capSQLiteResult>} {changes:{changes:number}}
* @returns {Promise<capSQLiteChanges>}
* @since 2.0.1-1
*/
createSyncTable(): Promise<capSQLiteResult>;
createSyncTable(): Promise<capSQLiteChanges>;
/**
* Set the synchronization date
* @param {capSQLiteOptions} options {syncdate: string}
* @returns {Promise<capSQLiteResult>} {result:boolean}
* @param {capSQLiteSyncDateOptions} options
* @returns {Promise<capSQLiteResult>}
* @since 2.0.1-1
*/
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>;
setSyncDate(options: capSQLiteSyncDateOptions): Promise<capSQLiteResult>;
}
export interface capEchoOptions {
/**
* String to be echoed
*/
value?: string;
}
export interface capSQLiteOptions {

@@ -101,9 +123,26 @@ /**

/**
* Set to true (database encryption) / false
* - Open method only
*/
encrypted?: boolean;
/**
* Set the mode for database encryption
* ["encryption", "secret", "newsecret"]
* - Open method only
*/
mode?: string;
}
export interface capSQLiteExecuteOptions {
/**
* The batch of raw SQL statements as string
*/
statements?: string;
}
export interface capSQLiteSetOptions {
/**
* The batch of raw SQL statements as Array of capSQLLiteSet
*/
set?: Array<capSQLiteSet>;
set?: capSQLiteSet[];
}
export interface capSQLiteRunOptions {
/**

@@ -116,13 +155,16 @@ * A statement

*/
values?: Array<any>;
values?: any[];
}
export interface capSQLiteQueryOptions {
/**
* Set to true for database encryption
* A statement
*/
encrypted?: boolean;
/***
* Set the mode for database encryption
* ["encryption", "secret","newsecret"]
statement?: string;
/**
* A set of values for a statement
*/
mode?: string;
/***
values?: string[];
}
export interface capSQLiteImportOptions {
/**
* Set the JSON object to import

@@ -132,9 +174,13 @@ *

jsonstring?: string;
/***
* Set the mode to export JSON Object
* "full", "partial"
}
export interface capSQLiteExportOptions {
/**
* Set the mode to export JSON Object:
* "full" or "partial"
*
*/
jsonexportmode?: string;
/***
}
export interface capSQLiteSyncDateOptions {
/**
* Set the synchronization date

@@ -145,2 +191,18 @@ *

}
export interface capSQLiteSet {
/**
* A statement
*/
statement?: string;
/**
* the data values list as an Array
*/
values?: any[];
}
export interface capEchoResult {
/**
* String returned
*/
value?: string;
}
export interface capSQLiteResult {

@@ -152,2 +214,8 @@ /**

/**
* a returned message
*/
message?: string;
}
export interface capSQLiteChanges {
/**
* the number of changes from an execute or run command

@@ -157,23 +225,86 @@ */

/**
* a returned message
*/
message?: string;
}
export interface capSQLiteValues {
/**
* the data values list as an Array
*/
values?: Array<any>;
values?: any[];
/**
* a message
* a returned message
*/
message?: string;
}
export interface capSQLiteJson {
/**
* an export JSON object
*/
export?: any;
export?: JsonSQLite;
/**
* a returned message
*/
message?: string;
}
export interface capSQLiteSet {
export interface JsonSQLite {
/**
* A statement
* The database name
*/
statement?: String;
database: string;
/**
* the data values list as an Array
* Set to true (database encryption) / false
*/
values?: Array<any>;
encrypted: boolean;
/***
* Set the mode
* ["full", "partial"]
*/
mode: string;
/***
* Array of Table (JsonTable)
*/
tables: JsonTable[];
}
export interface JsonTable {
/**
* The database name
*/
name: string;
/***
* Array of Schema (JsonColumn)
*/
schema?: JsonColumn[];
/***
* Array of Index (JsonIndex)
*/
indexes?: JsonIndex[];
/***
* Array of Table data
*/
values?: any[][];
}
export interface JsonColumn {
/**
* The column name
*/
column?: string;
/**
* The column data (type, unique, ...)
*/
value: string;
/**
* The column foreign key constraints
*/
foreignkey?: string;
}
export interface JsonIndex {
/**
* The index name
*/
name: string;
/**
* The column name to be indexed
*/
column: string;
}

@@ -0,1 +1,5 @@

;
;
;
;
//# sourceMappingURL=definitions.js.map
import { UtilsSQLite } from './UtilsSQLite';
import {
JsonSQLite,
JsonTable,
JsonIndex,
JsonColumn,
isJsonSQLite,
isTable,
} from './JsonUtils';
import { JsonSQLite, JsonTable, JsonColumn, JsonIndex } from '../definitions';
import { isJsonSQLite, isTable } from './JsonUtils';
export class DatabaseSQLiteHelper {

@@ -409,2 +404,3 @@ public isOpen: boolean = false;

statements.push(`DROP TABLE IF EXISTS ${jsonData.tables[i].name};`);
// create table
statements.push(

@@ -445,2 +441,6 @@ `CREATE TABLE IF NOT EXISTS ${jsonData.tables[i].name} (`,

statements.push(');');
// create trigger last_modified associated with the table
statements.push(
`CREATE TRIGGER IF NOT EXISTS ${jsonData.tables[i].name}_trigger_last_modified AFTER UPDATE ON ${jsonData.tables[i].name} FOR EACH ROW WHEN NEW.last_modified <= OLD.last_modified BEGIN UPDATE ${jsonData.tables[i].name} SET last_modified = (strftime('%s','now')) WHERE id=OLD.id; END;`,
);
}

@@ -447,0 +447,0 @@ if (

@@ -1,23 +0,1 @@

/* JSON Types */
export type JsonSQLite = {
database: string;
encrypted: boolean;
mode: string;
tables: Array<JsonTable>;
};
export type JsonTable = {
name: string;
schema?: Array<JsonColumn>;
indexes?: Array<JsonIndex>;
values?: Array<Array<any>>;
};
export type JsonColumn = {
column?: string;
value: string;
foreignkey?: string;
};
export type JsonIndex = {
name: string;
column: string;
};
/* JSON function */

@@ -24,0 +2,0 @@ export function isJsonSQLite(obj: any): boolean {

import { WebPlugin } from '@capacitor/core';
import {
CapacitorSQLitePlugin,
capEchoOptions,
capSQLiteOptions,
capSQLiteExecuteOptions,
capSQLiteSetOptions,
capSQLiteRunOptions,
capSQLiteQueryOptions,
capSQLiteImportOptions,
capSQLiteExportOptions,
capSQLiteSyncDateOptions,
capEchoResult,
capSQLiteResult,
capSQLiteChanges,
capSQLiteValues,
capSQLiteJson,
} from './definitions';

@@ -28,3 +40,3 @@ import { DatabaseSQLiteHelper } from './electron-utils/DatabaseSQLiteHelper';

}
async echo(options: { value: string }): Promise<{ value: string }> {
async echo(options: capEchoOptions): Promise<capEchoResult> {
console.log('ECHO in CapacitorSQLiteElectronWeb ', options);

@@ -73,3 +85,3 @@ console.log(this.RemoteRef);

}
async execute(options: capSQLiteOptions): Promise<capSQLiteResult> {
async execute(options: capSQLiteExecuteOptions): Promise<capSQLiteChanges> {
const retRes = { changes: -1 };

@@ -86,3 +98,3 @@ if (typeof options.statements === 'undefined') {

}
async executeSet(options: capSQLiteOptions): Promise<capSQLiteResult> {
async executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges> {
const retRes = { changes: -1 };

@@ -119,3 +131,3 @@ if (typeof options.set === 'undefined') {

}
async run(options: capSQLiteOptions): Promise<capSQLiteResult> {
async run(options: capSQLiteRunOptions): Promise<capSQLiteChanges> {
const retRes = { changes: -1 };

@@ -144,6 +156,6 @@ if (typeof options.statement === 'undefined') {

}
async query(options: capSQLiteOptions): Promise<capSQLiteResult> {
async query(options: capSQLiteQueryOptions): Promise<capSQLiteValues> {
if (typeof options.statement === 'undefined') {
return Promise.reject({
changes: -1,
values: [],
message: 'Query command failed : Must provide a SQL statement',

@@ -154,3 +166,3 @@ });

return Promise.reject({
changes: -1,
values: [],
message: 'Query command failed : Values should be an Array of values',

@@ -216,3 +228,3 @@ });

}
async isJsonValid(options: capSQLiteOptions): Promise<capSQLiteResult> {
async isJsonValid(options: capSQLiteImportOptions): Promise<capSQLiteResult> {
const jsonStrObj = options.jsonstring;

@@ -240,3 +252,5 @@ if (

}
async importFromJson(options: capSQLiteOptions): Promise<capSQLiteResult> {
async importFromJson(
options: capSQLiteImportOptions,
): Promise<capSQLiteChanges> {
const retRes = { changes: -1 };

@@ -268,3 +282,3 @@ const jsonStrObj = options.jsonstring;

}
async exportToJson(options: capSQLiteOptions): Promise<capSQLiteResult> {
async exportToJson(options: capSQLiteExportOptions): Promise<capSQLiteJson> {
const retRes = {};

@@ -290,7 +304,9 @@ if (typeof options.jsonexportmode === 'undefined') {

}
async createSyncTable(): Promise<capSQLiteResult> {
async createSyncTable(): Promise<capSQLiteChanges> {
const ret: any = await this.mDb.createSyncTable();
return Promise.resolve({ changes: ret });
}
async setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult> {
async setSyncDate(
options: capSQLiteSyncDateOptions,
): Promise<capSQLiteResult> {
if (

@@ -297,0 +313,0 @@ typeof options.syncdate === 'undefined' ||

{
"name": "@capacitor-community/sqlite",
"version": "2.4.2-2",
"version": "2.4.2-3",
"description": "Capacitor SQLite Plugin",

@@ -17,2 +17,3 @@ "homepage": "https://github.com/capacitor-community/sqlite",

"watch": "tsc --watch",
"docgen": "docgen --api CapacitorSQLitePlugin --output-readme docs/API.md",
"prepublishOnly": "npm run build"

@@ -25,2 +26,3 @@ },

"@capacitor/core": "^2.4.2",
"@capacitor/docgen": "0.0.4",
"@capacitor/ios": "^2.4.2",

@@ -27,0 +29,0 @@ "@ionic/prettier-config": "^1.0.0",

@@ -136,3 +136,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>

[API_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/APIdocumentation.md)
[API_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/API.md)

@@ -139,0 +139,0 @@ [ImportExportJson_Documentation](https://github.com/capacitor-community/sqlite/blob/master/docs/ImportExportJson.md)

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

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

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