Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 2.62 KB

NonConformedDatabases.md

File metadata and controls

95 lines (69 loc) · 2.62 KB


Non Conformed Databases DOCUMENTATION

@capacitor-community/sqlite

Capacitor community plugin for Native and Electron SQLite Databases. For Native, databases could be encrypted with SQLCipher

The following methods have been developed to allow connections to existing sqlite databases created by other plugins without the SQLite.db extension. Those connections will then access databases in Read-Only mode.

Index

Methods

getNCDatabasePath

This method allows to get the path of the database giving the folder path and the database name.

The folder path can be any folder under

  • Applications, Library or Documents for iOS
  • databases or files for Android
...
  this.sqlitePlugin = CapacitorSQLite;
  this.sqlite = new SQLiteConnection(this.sqlitePlugin);
...
  let directory: string;
  if(this.platform === "ios") directory = "Applications/Files/Databases"
  if(this.platform === "android" ) directory = "files/databases";  
  const databasePath = (await this.sqlite.getNCDatabasePath(directory,"testncdb.db")).path;

isNCDatabase

This method checks if a database path exists prior to create a connection

...
  const isNCDbExists = (await this.sqlite.isNCDatabase(databasePath)).result;
...

isNCConnection

This method checks if a non-conformed connection exists

...
  const isConn = (await this.sqlite.isNCConnection(databasePath)).result;
...

createNCConnection

This method create a Read-Only connection for a given database path

...
  db = await this.sqlite.createNCConnection(databasePath, 1);
...

closeeNCConnection

This method close a Read-Only connection for a given database path

...
  db = await this.sqlite.closeNCConnection(databasePath, 1);
...

retrieveNCConnection

This method retrieve a Read-Only connection for a given database path

...
  db = await this.sqlite.retrieveNCConnection(databasePath);
...

Ionic/Angular Example

Have a look at testncdbspage component in angular-sqlite-app-starter