@capacitor-community/sqlite
Advanced tools
Comparing version 2.4.1-devversion.3 to 2.4.2-1
@@ -1,19 +0,19 @@ | ||
## 2.4.1-devversion.3 (2020-09-02) | ||
## 2.4.2-1 (2020-09-29) | ||
### Added Features | ||
### Chores | ||
- add Upgrade Database Version documentation | ||
- Capacitor: update 2.4.2 | ||
## 2.4.1-devversion.2 (2020-08-31) | ||
### ### Added Features | ||
### Bug Fixes | ||
- The electron plugin is now compatible with @capacitor-community/electron | ||
- some fixes for Handling version in Electron platform | ||
## 2.4.1-1 (2020-09-22) | ||
## 2.4.1-devversion.1 (2020-08-31) | ||
### Bug Fixes | ||
### Added Features (alpha not to be used in production) | ||
- Fix Better permission request on Android issue#40 | ||
- Update APIdocumentation.md, .gitignore & .npmignore | ||
- Fix bug in setSyncDate iOS & electron | ||
- add Handling version in Electron platform | ||
## 2.4.0 (2020-08-07) | ||
@@ -20,0 +20,0 @@ |
@@ -89,9 +89,2 @@ declare module '@capacitor/core' { | ||
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>; | ||
/** | ||
* Add an upgrade statement | ||
* @param {string} database Database Name | ||
* @param {capSQLiteVersionUpgrade} upgrade {fromVersion: number, toVersion: number, statement?: string, set?: Array<capSQLiteSet>} | ||
* @returns {Promise<capSQLiteResult>} {result:boolean} | ||
*/ | ||
addUpgradeStatement(database: string, upgrade: capSQLiteVersionUpgrade): Promise<capSQLiteResult>; | ||
} | ||
@@ -129,6 +122,2 @@ export interface capSQLiteOptions { | ||
/*** | ||
* Set Database Version | ||
*/ | ||
version?: number; | ||
/*** | ||
* Set the JSON object to import | ||
@@ -182,7 +171,1 @@ * | ||
} | ||
export interface capSQLiteVersionUpgrade { | ||
fromVersion: number; | ||
toVersion: number; | ||
statement?: string; | ||
set?: Array<capSQLiteSet>; | ||
} |
export * from './definitions'; | ||
export * from './web'; | ||
export * from './electron'; |
export * from './definitions'; | ||
export * from './web'; | ||
export * from './electron'; | ||
//# sourceMappingURL=index.js.map |
import { WebPlugin } from '@capacitor/core'; | ||
import { CapacitorSQLitePlugin, capSQLiteOptions, capSQLiteResult, capSQLiteVersionUpgrade } from './definitions'; | ||
import { CapacitorSQLitePlugin, capSQLiteOptions, capSQLiteResult } from './definitions'; | ||
export declare class CapacitorSQLiteWeb extends WebPlugin implements CapacitorSQLitePlugin { | ||
@@ -23,5 +23,4 @@ constructor(); | ||
setSyncDate(options: capSQLiteOptions): Promise<capSQLiteResult>; | ||
addUpgradeStatement(database: string, upgrade: capSQLiteVersionUpgrade): Promise<capSQLiteResult>; | ||
} | ||
declare const CapacitorSQLite: CapacitorSQLiteWeb; | ||
export { CapacitorSQLite }; |
@@ -20,3 +20,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('ECHO', options); | ||
console.log('ECHO in Web plugin', options); | ||
return options; | ||
@@ -28,3 +28,3 @@ }); | ||
console.log('open', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -35,3 +35,3 @@ } | ||
console.log('close', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -42,3 +42,3 @@ } | ||
console.log('execute', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -49,3 +49,3 @@ } | ||
console.log('execute', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -56,3 +56,3 @@ } | ||
console.log('run', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -63,3 +63,3 @@ } | ||
console.log('query', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -69,4 +69,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('isDBExists', options); | ||
return Promise.reject('Not implemented'); | ||
console.log('in Web isDBExists', options); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -77,3 +77,3 @@ } | ||
console.log('deleteDatabase', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -84,3 +84,3 @@ } | ||
console.log('isJsonValid', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -91,3 +91,3 @@ } | ||
console.log('importFromJson', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -98,3 +98,3 @@ } | ||
console.log('exportToJson', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -105,3 +105,3 @@ } | ||
console.log('createSyncTable'); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
@@ -112,11 +112,5 @@ } | ||
console.log('setSyncDate', options); | ||
return Promise.reject('Not implemented'); | ||
return Promise.reject('Not implemented on Web Platform'); | ||
}); | ||
} | ||
addUpgradeStatement(database, upgrade) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
console.log('addUpgradeStatement', database, upgrade); | ||
return Promise.resolve({ result: false, message: 'Not implemented' }); | ||
}); | ||
} | ||
} | ||
@@ -123,0 +117,0 @@ const CapacitorSQLite = new CapacitorSQLiteWeb(); |
{ | ||
"name": "@capacitor-community/sqlite", | ||
"version": "2.4.1-devversion.3", | ||
"version": "2.4.2-1", | ||
"description": "Capacitor SQLite Plugin", | ||
@@ -14,2 +14,3 @@ "homepage": "https://github.com/capacitor-community/sqlite", | ||
"build": "npm run clean && tsc && rollup -c rollup.config.js", | ||
"build-electron": "rimraf ./electron/dist && cd ./electron && tsc && rollup --config rollup.config.js", | ||
"clean": "rimraf ./dist", | ||
@@ -22,11 +23,12 @@ "watch": "tsc --watch", | ||
"devDependencies": { | ||
"@capacitor/android": "^2.4.0", | ||
"@capacitor/core": "^2.4.0", | ||
"@capacitor/ios": "^2.4.0", | ||
"@capacitor/android": "^2.4.2", | ||
"@capacitor/core": "^2.4.2", | ||
"@capacitor/ios": "^2.4.2", | ||
"@ionic/prettier-config": "^1.0.0", | ||
"@ionic/swiftlint-config": "^1.1.1", | ||
"@rollup/plugin-node-resolve": "^8.4.0", | ||
"@types/node": "^13.13.2", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@types/node": "^12.12.62", | ||
"electron": "^10.1.2", | ||
"husky": "^4.2.5", | ||
"np": "^6.5.0", | ||
"np": "^6.3.2", | ||
"prettier": "^2.0.5", | ||
@@ -36,4 +38,6 @@ "prettier-plugin-java": "^0.8.1", | ||
"rimraf": "^3.0.0", | ||
"rollup": "^2.21.0", | ||
"rollup": "^2.28.1", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"swiftlint": "^1.0.1", | ||
"tslib": "^1.13.0", | ||
"typescript": "^3.9.6" | ||
@@ -47,3 +51,3 @@ }, | ||
"peerDependencies": { | ||
"@capacitor/core": "^2.4.0" | ||
"@capacitor/core": "^2.4.2" | ||
}, | ||
@@ -54,3 +58,4 @@ "files": [ | ||
"android/", | ||
"CapacitorCommunitySqlite.podspec" | ||
"electron/", | ||
"CommunitySqlite.podspec" | ||
], | ||
@@ -70,2 +75,5 @@ "keywords": [ | ||
"src": "android" | ||
}, | ||
"electron": { | ||
"src": "electron/dist/plugin.js" | ||
} | ||
@@ -81,3 +89,4 @@ }, | ||
"url": "https://github.com/capacitor-community/sqlite/issues" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
185
README.md
@@ -31,125 +31,82 @@ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p> | ||
npx cap sync | ||
npx cap add ios | ||
npx cap add android | ||
npx cap add @capacitor-community/electron | ||
``` | ||
### iOS | ||
- On iOS, no further steps are needed. | ||
### Android | ||
- On Android, register the plugin in your main activity: | ||
```java | ||
import com.getcapacitor.community.database.sqlite.CapacitorSQLite; | ||
```java | ||
import com.getcapacitor.community.database.sqlite.CapacitorSQLite; | ||
public class MainActivity extends BridgeActivity { | ||
public class MainActivity extends BridgeActivity { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// Initializes the Bridge | ||
this.init( | ||
savedInstanceState, | ||
new ArrayList<Class<? extends Plugin>>() { | ||
// Initializes the Bridge | ||
this.init( | ||
savedInstanceState, | ||
new ArrayList<Class<? extends Plugin>>() { | ||
{ | ||
// Additional plugins you've installed go here | ||
// Ex: add(TotallyAwesomePlugin.class); | ||
add(CapacitorSQLite.class); | ||
} | ||
{ | ||
// Additional plugins you've installed go here | ||
// Ex: add(TotallyAwesomePlugin.class); | ||
add(CapacitorSQLite.class); | ||
} | ||
); | ||
} | ||
} | ||
); | ||
} | ||
``` | ||
} | ||
- On Electron, go to the Electron folder of YOUR_APPLICATION | ||
``` | ||
```bash | ||
npm install --save sqlite3 | ||
npm install --save-dev @types/sqlite3 | ||
npm install --save-dev electron-rebuild | ||
``` | ||
### Electron | ||
Modify the Electron package.json file by adding a script "postinstall" | ||
- On Electron, go to the Electron folder of YOUR_APPLICATION | ||
```json | ||
"scripts": { | ||
"electron:start": "electron ./", | ||
"postinstall": "electron-rebuild -f -w sqlite3" | ||
}, | ||
``` | ||
```bash | ||
npm install --save sqlite3 | ||
npm install --save-dev @types/sqlite3 | ||
npm install --save-dev electron-rebuild | ||
``` | ||
Execute the postinstall script | ||
Modify the Electron package.json file by adding a script "postinstall" | ||
```bash | ||
npm run postinstall | ||
``` | ||
```json | ||
"scripts": { | ||
"electron:start": "electron ./", | ||
"postinstall": "electron-rebuild -f -w sqlite3" | ||
}, | ||
``` | ||
Go back in the main folder of your application | ||
Add a script in the index.html file of your application in the body tag | ||
Execute the postinstall script | ||
- case databases under `YourApplication/Electron/` | ||
```bash | ||
npm run postinstall | ||
``` | ||
```html | ||
<body> | ||
<app-root></app-root> | ||
<script> | ||
try { | ||
if ( | ||
process && | ||
typeof process.versions.electron === 'string' && | ||
process.versions.hasOwnProperty('electron') | ||
) { | ||
const sqlite3 = require('sqlite3'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
window.sqlite3 = sqlite3; | ||
window.fs = fs; | ||
window.path = path; | ||
} | ||
} catch { | ||
console.log("process doesn't exists"); | ||
} | ||
</script> | ||
</body> | ||
``` | ||
#### Electron databases location | ||
- case databases under `User/Databases/APP_NAME/` | ||
- There are by default under `User/Databases/APP_NAME/` | ||
```html | ||
<body> | ||
<app-root></app-root> | ||
<script> | ||
try { | ||
if ( | ||
process && | ||
typeof process.versions.electron === 'string' && | ||
process.versions.hasOwnProperty('electron') | ||
) { | ||
const sqlite3 = require('sqlite3'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const homeDir = require('os').homedir(); | ||
window.sqlite3 = sqlite3; | ||
window.fs = fs; | ||
window.path = path; | ||
window.appName = 'YOUR_APP_NAME'; | ||
window.homeDir = homeDir; | ||
} | ||
} catch { | ||
console.log("process doesn't exists"); | ||
} | ||
</script> | ||
</body> | ||
``` | ||
Then build YOUR_APPLICATION | ||
Then build YOUR_APPLICATION | ||
``` | ||
npm run build | ||
npx cap copy | ||
npx cap copy @capacitor-community/electron | ||
npx cap copy web | ||
npx cap open android | ||
npx cap open ios | ||
npx cap open @capacitor-community/electron | ||
``` | ||
``` | ||
npm run build | ||
npx cap copy | ||
npx cap copy web | ||
npx cap open android | ||
npx cap open ios | ||
npx cap open electron | ||
``` | ||
## Configuration | ||
@@ -177,3 +134,2 @@ | ||
| isDBExists | ✅ | ✅ | ✅ | ❌ | | ||
| addUpgradeStatement | ❌ | ❌ | ✅ | ❌ | | ||
@@ -309,2 +265,29 @@ ## Documentation | ||
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(); | ||
if (info.platform === "android") { | ||
this._sqlite = CapacitorSQLite; | ||
try { | ||
// Show request popup | ||
await this._sqlite.requestPermissions(); | ||
} catch (e) { | ||
// Permissions declined | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
## Dependencies | ||
@@ -325,6 +308,4 @@ | ||
<td align="center"><a href="https://github.com/jepiqueau"><img src="https://avatars3.githubusercontent.com/u/16580653?v=4" width="100px;" alt=""/><br /><sub><b>Jean Pierre Quéau</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/paulantoine2"><img src="https://avatars0.githubusercontent.com/u/22882943?s=64&v=4" width="100px;" alt=""/><br /><sub><b>Paul Antoine</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=jepiqueau" title="Code">💻</a></td> | ||
</tr> | ||
<tr> | ||
<td align="center"><a href="https://github.com/karyfars"><img src="https://avatars3.githubusercontent.com/u/303016" width="100px;" alt=""/><br /><sub><b>Adam</b></sub></a><br /><a href="https://github.com/capacitor-community/sqlite/commits?author=karyfars" title="Code">💻</a></td> | ||
</tr> | ||
</table> | ||
@@ -331,0 +312,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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10218759
173
7151
19
315
6
2