SQLCipher Native Plugin for React Native for Android/iOS. This plugin provides a WebSQL-compatible API to store data in a react native app, by using a SQLCipher database on the native side.
Forked from React native SQlite 2
$ npm install react-native-sqlcipher-2 --save$ react-native link react-native-sqlcipher-2Add the following to your Podfile
pod 'SQLCipher'
importSQLite,{encodeName}from'react-native-sqlcipher-2';constdb=SQLite.openDatabase(encodeName('test.db','testpassword'),'1.0','',1);db.transaction(function(txn){txn.executeSql('DROP TABLE IF EXISTS Users',[]);txn.executeSql('CREATE TABLE IF NOT EXISTS Users(user_id INTEGER PRIMARY KEY NOT NULL, name VARCHAR(30))',[]);txn.executeSql('INSERT INTO Users (name) VALUES (:name)',['nora']);txn.executeSql('INSERT INTO Users (name) VALUES (:name)',['takuya']);txn.executeSql('SELECT * FROM `users`',[],function(tx,res){for(leti=0;i<res.rows.length;++i){console.log('item:',res.rows.item(i));}});});There is a test app in the test directory.
It can be used with pouchdb-adapter-react-native-sqlite.
importPouchDBfrom'pouchdb-react-native'importSQLite,{encodeName}from'react-native-sqlcipher-2'importSQLiteAdapterFactoryfrom'pouchdb-adapter-react-native-sqlite'constSQLiteAdapter=SQLiteAdapterFactory(SQLite)PouchDB.plugin(SQLiteAdapter)vardb=newPouchDB(encodeName('test','testpassword'),{adapter: 'react-native-sqlite'})