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-8 to 2.4.2-9

11

CHANGELOG.md

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

## 2.4.2-9 (2020-11-12)
### Added Features
- Add Listener for request permissions (Android)
- Add Vue and Ionic/Vue demonstrating apps
### Bug Fixes
- Update documentation
## 2.4.2-8 (2020-10-22)

@@ -2,0 +13,0 @@

70

dist/esm/web.js

@@ -27,3 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

console.log('open', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -34,3 +37,6 @@ }

console.log('close', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -41,3 +47,6 @@ }

console.log('execute', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -48,3 +57,6 @@ }

console.log('execute', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -55,3 +67,6 @@ }

console.log('run', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -62,3 +77,6 @@ }

console.log('query', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -69,3 +87,6 @@ }

console.log('in Web isDBExists', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -76,3 +97,6 @@ }

console.log('deleteDatabase', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -83,3 +107,6 @@ }

console.log('isJsonValid', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -90,3 +117,6 @@ }

console.log('importFromJson', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -97,3 +127,6 @@ }

console.log('exportToJson', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -104,3 +137,6 @@ }

console.log('createSyncTable');
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -111,3 +147,6 @@ }

console.log('setSyncDate', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -118,3 +157,6 @@ }

console.log('addUpgradeStatement', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -121,0 +163,0 @@ }

@@ -29,3 +29,6 @@ var capacitorPlugin = (function (exports, core) {

console.log('open', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -36,3 +39,6 @@ }

console.log('close', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -43,3 +49,6 @@ }

console.log('execute', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -50,3 +59,6 @@ }

console.log('execute', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -57,3 +69,6 @@ }

console.log('run', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -64,3 +79,6 @@ }

console.log('query', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -71,3 +89,6 @@ }

console.log('in Web isDBExists', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -78,3 +99,6 @@ }

console.log('deleteDatabase', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -85,3 +109,6 @@ }

console.log('isJsonValid', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -92,3 +119,6 @@ }

console.log('importFromJson', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -99,3 +129,6 @@ }

console.log('exportToJson', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -106,3 +139,6 @@ }

console.log('createSyncTable');
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -113,3 +149,6 @@ }

console.log('setSyncDate', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -120,3 +159,6 @@ }

console.log('addUpgradeStatement', options);
return Promise.reject('Not implemented on Web Platform');
return Promise.resolve({
result: false,
message: `Not implemented on Web Platform`,
});
});

@@ -123,0 +165,0 @@ }

3

electron/dist/esm/src/definitions.d.ts

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

* @returns Promise<capSQLiteResult>
* @since 2.4.2-6 iOS & Electron
* @since 2.4.2-7 Android
* @since 2.4.2-6 iOS & Electron 2.4.2-7 Android
*/

@@ -113,0 +112,0 @@ addUpgradeStatement(options: capSQLiteUpgradeOptions): Promise<capSQLiteResult>;

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

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

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

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

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

### Ionic/Vue
- [vue-sqlite-app-starter](https://github.com/jepiqueau/vue-sqlite-app-starter)
### Vue
- [vue-sqlite-app](https://github.com/jepiqueau/vue-sqlite-app)
## Usage

@@ -163,97 +171,120 @@

```ts
import { Plugins } from '@capacitor/core';
import { Plugins, Capacitor } from '@capacitor/core';
import '@capacitor-community/sqlite';
const { CapacitorSQLite,Device } = Plugins;
const { CapacitorSQLite } = Plugins;
@Component( ... )
export class MyPage {
_sqlite: any;
_platform: string
_sqlite: any;
_platform: string;
_isPermission: boolean = true;
...
...
async ngAfterViewInit()() {
const info = await Device.getInfo();
this._platform = info.platform;
this._sqlite = CapacitorSQLite;
ngAfterViewInit()() {
this._platform = Capacitor.platform;
this._sqlite = CapacitorSQLite;
if (this._platform === 'android') {
const handlerPermissions = this.sqlite.addListener(
'androidPermissionsRequest', async (data:any) => {
if (data.permissionGranted === 1) {
this._isPermission = true;
} else {
this._isPermission = false;
}
});
try {
this.sqlite.requestPermissions();
} catch (e) {
console.log('Error requesting permissions!' + JSON.stringify(e));
}
}
...
}
}
async testSQLitePlugin() {
let result:any = await this._sqlite.open({database:"testsqlite"});
retOpenDB = result.result;
if(retOpenDB) {
// Create Tables if not exist
let sqlcmd: string = `
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY NOT NULL,
email TEXT UNIQUE NOT NULL,
name TEXT,
FirstName TEXT,
age INTEGER,
MobileNumber TEXT
);
PRAGMA user_version = 1;
COMMIT TRANSACTION;
`;
var retExe: any = await this._sqlite.execute({statements:sqlcmd});
console.log('retExe ',retExe.changes.changes);
// Insert some Users
sqlcmd = `
BEGIN TRANSACTION;
DELETE FROM users;
INSERT INTO users (name,email,age) VALUES ("Whiteley","Whiteley.com",30);
INSERT INTO users (name,email,age) VALUES ("Jones","Jones.com",44);
COMMIT TRANSACTION;
`;
retExe = await this._sqlite.execute({statements:sqlcmd});
// will print the changes 2 in that case
console.log('retExe ',retExe.changes.changes);
// Select all Users
sqlcmd = "SELECT * FROM users";
const retSelect: any = await this._sqlite.query({statement:sqlcmd,values:[]});
console.log('retSelect.values.length ',retSelect.values.length);
const row1: any = retSelect.values[0];
console.log("row1 users ",JSON.stringify(row1))
const row2: any = retSelect.values[1];
console.log("row2 users ",JSON.stringify(row2))
async testSQLitePlugin(): Promise<void> {
if(!this._isPermission) {
console.log("Android permissions not granted");
return;
}
let result:any = await this._sqlite.open({database:"testsqlite"});
retOpenDB = result.result;
if(retOpenDB) {
// Create Tables if not exist
let sqlcmd: string = `
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY NOT NULL,
email TEXT UNIQUE NOT NULL,
name TEXT,
FirstName TEXT,
age INTEGER,
MobileNumber TEXT
);
PRAGMA user_version = 1;
COMMIT TRANSACTION;
`;
var retExe: any = await this._sqlite.execute({statements:sqlcmd});
console.log('retExe ',retExe.changes.changes);
// Insert some Users
sqlcmd = `
BEGIN TRANSACTION;
DELETE FROM users;
INSERT INTO users (name,email,age) VALUES ("Whiteley","Whiteley.com",30);
INSERT INTO users (name,email,age) VALUES ("Jones","Jones.com",44);
COMMIT TRANSACTION;
`;
retExe = await this._sqlite.execute({statements:sqlcmd});
// will print the changes 2 in that case
console.log('retExe ',retExe.changes.changes);
// Select all Users
sqlcmd = "SELECT * FROM users";
const retSelect: any = await this._sqlite.query({statement:sqlcmd,values:[]});
console.log('retSelect.values.length ',retSelect.values.length);
const row1: any = retSelect.values[0];
console.log("row1 users ",JSON.stringify(row1))
const row2: any = retSelect.values[1];
console.log("row2 users ",JSON.stringify(row2))
// Insert a new User with SQL and Values
// Insert a new User with SQL and Values
sqlcmd = "INSERT INTO users (name,email,age) VALUES (?,?,?)";
let values: Array<any> = ["Simpson","Simpson@example.com",69];
var retRun: any = await this._sqlite.run({statement:sqlcmd,values:values});
console.log('retRun ',retRun.changes.changes,retRun.changes.lastId);
sqlcmd = "INSERT INTO users (name,email,age) VALUES (?,?,?)";
let values: Array<any> = ["Simpson","Simpson@example.com",69];
var retRun: any = await this._sqlite.run({statement:sqlcmd,values:values});
console.log('retRun ',retRun.changes.changes,retRun.changes.lastId);
// Select Users with age > 35
sqlcmd = "SELECT name,email,age FROM users WHERE age > ?";
retSelect = await this._sqlite.query({statement:sqlcmd,values:["35"]});
console.log('retSelect ',retSelect.values.length);
// Select Users with age > 35
sqlcmd = "SELECT name,email,age FROM users WHERE age > ?";
retSelect = await this._sqlite.query({statement:sqlcmd,values:["35"]});
console.log('retSelect ',retSelect.values.length);
// Execute a Set of raw SQL Statements
let set: Array<any> = [
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Blackberry","Peter","Blackberry@example.com",69,"4405060708"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Jones","Helen","HelenJones@example.com",42,"4404030201"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Davison","Bill","Davison@example.com",45,"4405162732"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Brown","John","Brown@example.com",35,"4405243853"]
},
{ statement:"UPDATE users SET age = ? , MobileNumber = ? WHERE id = ?;",
values:[51,"4404030237",2]
}
];
result = await this._sqlite.executeSet({set:set});
console.log("result.changes.changes ",result.changes.changes)
if(result.changes.changes != 5) resolve(false);
// Execute a Set of raw SQL Statements
let set: Array<any> = [
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Blackberry","Peter","Blackberry@example.com",69,"4405060708"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Jones","Helen","HelenJones@example.com",42,"4404030201"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Davison","Bill","Davison@example.com",45,"4405162732"]
},
{ statement:"INSERT INTO users (name,FirstName,email,age,MobileNumber) VALUES (?,?,?,?,?);",
values:["Brown","John","Brown@example.com",35,"4405243853"]
},
{ statement:"UPDATE users SET age = ? , MobileNumber = ? WHERE id = ?;",
values:[51,"4404030237",2]
}
];
result = await this._sqlite.executeSet({set:set});
console.log("result.changes.changes ",result.changes.changes);
if(result.changes.changes != 5) return;
...
}
} else {
console.log("Error: Open database failed");
return;
}
}

@@ -264,29 +295,2 @@ ...

On android, you must request permissions to read and write in storage :
```ts
export class MyPage {
_sqlite: any;
...
async ngAfterViewInit()() {
const info = await Device.getInfo();
this._sqlite = CapacitorSQLite;
if (info.platform === "android") {
try {
// Show request popup
await this._sqlite.requestPermissions();
} catch (e) {
// Permissions declined
}
}
}
}
```
## Dependencies

@@ -293,0 +297,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 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