MyGit
๐Ÿšฉๆ”ถๅˆฐGitHubไป“ๅบ“็š„ๆ›ดๆ–ฐ้€š็Ÿฅ

capacitor-community/sqlite

Fork: 105 Star: 421 (ๆ›ดๆ–ฐไบŽ 2024-05-09 04:32:04)

license: MIT

Language: Swift .

Community plugin for native & electron SQLite databases

ๆœ€ๅŽๅ‘ๅธƒ็‰ˆๆœฌ๏ผš v6.0.0-alpha.1 ( 2024-05-06 15:38:47)

GitHub็ฝ‘ๅ€

โœจๅ…่ดน็”ณ่ฏท็ฝ‘็ซ™SSL่ฏไนฆ๏ผŒๆ”ฏๆŒๅคšๅŸŸๅๅ’Œๆณ›ๅŸŸๅ๏ผŒ็‚นๅ‡ปๆŸฅ็œ‹


SQLITE DATABASE

@capacitor-community/sqlite


CAPACITOR 5


Capacitor community plugin for Native and Electron SQLite Databases. - In Native, databases could be encrypted with `SQLCipher` - In Electron, databases could be encrypted with `better-sqlite3-multiple-ciphers`



Maintainers

Maintainer GitHub Social
Quรฉau Jean Pierre jepiqueau

To install:

npm install --save @capacitor-community/sqlite
npx cap sync
yarn add @capacitor-community/sqlite
npx cap sync
pnpm install --save @capacitor-community/sqlite
pnpm install --save @jeep-sqlite
pnpm install --save sql.js
npx cap sync

then add plugin to main capacitor.config.ts file:

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.jeep.app.ionic7.angular.sqlite',
  appName: 'ionic7-angular-sqlite-starter',
  webDir: 'www',
  server: {
    androidScheme: 'https'
  },
  plugins: {
    CapacitorSQLite: {
      iosDatabaseLocation: 'Library/CapacitorDatabase',
      iosIsEncryption: true,
      iosKeychainPrefix: 'angular-sqlite-app-starter',
      iosBiometric: {
        biometricAuth: false,
        biometricTitle : "Biometric login for capacitor sqlite"
      },
      androidIsEncryption: true,
      androidBiometric: {
        biometricAuth : false,
        biometricTitle : "Biometric login for capacitor sqlite",
        biometricSubTitle : "Log in using your biometric"
      },
      electronIsEncryption: true,
      electronWindowsLocation: "C:\\ProgramData\\CapacitorDatabases",
      electronMacLocation: "/Volumes/Development_Lacie/Development/Databases",
      electronLinuxLocation: "Databases"
    }
  }
};
export default config;

More Reading:

Tutorials Blog

Web Quirks

The plugin follows the guidelines from the Capacitor Team,

Meaning that it will not work in IE11 without additional JavaScript transformations, e.g. with Babel. You'll need the usual capacitor/android/react npm script to build and copy the assets folder.

For Angular framework

  • Copy manually the file sql-wasm.wasm from node_modules/sql.js/dist/sql-wasm.wasm to the src/assets folder of YOUR_APP

For Vue & React frameworks

  • Copy manually the file sql-wasm.wasm from node_modules/sql.js/dist/sql-wasm.wasm to the public/assets folder of YOUR_APP

Android Quirks

  • In case you get the following error when building your app in Android Studio: x files found with path 'build-data.properties'. You can you add the following code to app/build.gradle:
    packagingOptions {
        exclude 'build-data.properties'
    }

See #301 and SO question for more information.

  • Check/Add the following: Gradle JDK version 17 Android Gradle Plugin Version 8.0.0 In variables.gradle

    minSdkVersion = 22
    compileSdkVersion = 33
    targetSdkVersion = 33
    

    In AndroidManifest.xml

        <application
          android:allowBackup="false"
          android:fullBackupContent="false"
          android:dataExtractionRules="@xml/data_extraction_rules"
    

    In res/xml create a file data_extraction_rules.xml containing:

    <?xml version="1.0" encoding="utf-8"?>
    <data-extraction-rules>
        <cloud-backup>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
        </cloud-backup>
        <device-transfer>
          <exclude domain="root" />
          <exclude domain="database" />
          <exclude domain="sharedpref" />
          <exclude domain="external" />
        </device-transfer>
    </data-extraction-rules>
    

Electron Quirks

  • On Electron, go to the Electron folder of YOUR_APPLICATION
cd electron
npm install --save better-sqlite3-multiple-ciphers
npm install --save electron-json-storage
npm install --save jszip
npm install --save node-fetch@2.6.7
npm install --save crypto
npm install --save crypto-js
npm install --save-dev @types/better-sqlite3
npm install --save-dev @types/electron-json-storage
npm install --save-dev @types/crypto-js
  • Important: node-fetch version must be <=2.6.7; otherwise you'll get an error running the app.

  • Important: if you are using @capacitor-community/electron v5

npm install --save-dev electron@25.8.4
npm uninstall --save-dev electron-rebuild
npm install --save-dev @electron/rebuild
npm install --save-dev electron-builder@24.6.4
  • in electron folder open the tsconfig.json file and add "skipLibCheck": true,

IOS Quirks

  • on iOS, no further steps needed.

Supported Methods by Platform

Name Android iOS Electron Web
createConnection (ReadWrite) โœ… โœ… โœ… โœ…
createConnection (ReadOnly) โœ… โœ… โœ… โŒ
closeConnection (ReadWrite) โœ… โœ… โœ… โœ…
closeConnection (ReadOnly) โœ… โœ… โœ… โŒ
isConnection (ReadWrite) โœ… โœ… โœ… โœ…
isConnection (ReadOnly) โœ… โœ… โœ… โŒ
open (non-encrypted DB) โœ… โœ… โœ… โœ…
open (encrypted DB) โœ… โœ… โœ… โŒ
close โœ… โœ… โœ… โœ…
getUrl โœ… โœ… โŒ โŒ
getVersion โœ… โœ… โœ… โœ…
execute โœ… โœ… โœ… โœ…
executeSet โœ… โœ… โœ… โœ…
run โœ… โœ… โœ… โœ…
query โœ… โœ… โœ… โœ…
deleteDatabase โœ… โœ… โœ… โœ…
importFromJson โœ… โœ… โœ… โœ…
exportToJson โœ… โœ… โœ… โœ…
deleteExportedRows โœ… โœ… โœ… โœ…
createSyncTable โœ… โœ… โœ… โœ…
setSyncDate โœ… โœ… โœ… โœ…
getSyncDate โœ… โœ… โœ… โœ…
isJsonValid โœ… โœ… โœ… โœ…
isDBExists โœ… โœ… โœ… โœ…
addUpgradeStatement โœ… โœ… โœ… โœ…
copyFromAssets โœ… โœ… โœ… โœ…
isDBOpen โœ… โœ… โœ… โœ…
isDatabase โœ… โœ… โœ… โœ…
isTableExists โœ… โœ… โœ… โœ…
getTableList โœ… โœ… โœ… โœ…
getDatabaseList โœ… โœ… โœ… โœ…
getMigratableDbList โœ… โœ… โŒ โŒ
addSQLiteSuffix โœ… โœ… โŒ โŒ
deleteOldDatabases โœ… โœ… โŒ โŒ
moveDatabasesAndAddSuffix โœ… โœ… โŒ โŒ
checkConnectionsConsistency โœ… โœ… โœ… โœ…
isSecretStored โœ… โœ… โœ… โŒ
setEncryptionSecret โœ… โœ… โœ… โŒ
changeEncryptionSecret โœ… โœ… โœ… โŒ
clearEncryptionSecret โœ… โœ… โœ… โŒ
checkEncryptionSecret โœ… โœ… โœ… โŒ
initWebStore โŒ โŒ โŒ โœ…
saveToStore โŒ โŒ โŒ โœ…
getNCDatabasePath โœ… โœ… โŒ โŒ
createNCConnection โœ… โœ… โŒ โŒ
closeNCConnection โœ… โœ… โŒ โŒ
isNCDatabase โœ… โœ… โŒ โŒ
transaction โœ… โœ… โœ… โœ…
getFromHTTPRequest โœ… โœ… โœ… โœ…
isDatabaseEncrypted โœ… โœ… โœ… โŒ
isInConfigEncryption โœ… โœ… โœ… โŒ
isInConfigBiometricAuth โœ… โœ… โŒ โŒ
getFromLocalDiskToStore โŒ โŒ โŒ โœ…
saveToLocalDisk โŒ โŒ โŒ โœ…
beginTransaction โœ… โœ… โœ… โœ…
commitTransaction โœ… โœ… โœ… โœ…
rollbackTransaction โœ… โœ… โœ… โœ…
isTransactionActive โœ… โœ… โœ… โœ…

Documentation & APIs

Applications demonstrating the use of the plugin and related documentation

Ionic/Angular

Ionic/Angular TypeORM app (Not Updated)

Ionic/React

Ionic/React Capacitor SQLite + TypeORM Example App

Ionic/Vue

Vue (Not Updated)

Vue TypeORM app (Not Updated)

SolidJS+Vite (Not Updated)

Nuxt3 + Kysely

Quasar

SvelteKit

Dependencies

The iOS and Android codes are using SQLCipher allowing for database encryption. The iOS codes is using ZIPFoundation for unzipping assets files The Electron code is using better-sqlite3-multiple-ciphers , electron-json-storage and node-fetch from 5.0.4. The Web code is using the Stencil component jeep-sqlite based on sql.js, localforage. and jszip

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

ๆœ€่ฟ‘็‰ˆๆœฌๆ›ดๆ–ฐ:(ๆ•ฐๆฎๆ›ดๆ–ฐไบŽ 2024-05-09 04:31:47)

2024-05-06 15:38:47 v6.0.0-alpha.1

2024-04-29 02:13:41 v5.7.3-3

2024-04-23 19:12:55 v5.7.3-2

2024-04-23 03:33:11 v5.7.3-1

2024-04-10 01:28:28 v5.7.2

2024-04-03 19:29:30 v5.7.1

2024-03-28 01:10:58 v5.7.0

2024-03-27 22:50:16 v5.6.4

2024-03-12 18:48:49 v5.6.3

2024-03-07 22:33:27 v5.6.2

ไธป้ข˜(topics):

capacitor, sqlite

capacitor-community/sqliteๅŒ่ฏญ่จ€ Swiftๆœ€่ฟ‘ๆ›ดๆ–ฐไป“ๅบ“

2024-05-19 02:51:04 Artificial-Pancreas/iAPS

2024-05-17 03:42:13 realm/SwiftLint

2024-05-16 13:04:47 Dimillian/IceCubesApp

2024-05-15 04:01:41 wordpress-mobile/WordPress-iOS

2024-05-09 00:25:59 pointfreeco/swift-dependencies

2024-05-07 01:25:28 mrousavy/react-native-vision-camera