Installation

Configuration

Gotchas

Debugging

Reactive Queries

Libsql Support

Custom Tokenizers

API


osp_circle.png

By Oscar Franco

Twitter β€’ YouTube β€’ [Email](mailto:[email protected]?subject=I%20need%20a%20Freelancer)

Installing is easy

npm i -s @op-engineering/op-sqlite && npx pod-install

Configuration

SQLite is very customizable on compilation level. op-sqlite also allows you add extensions or even change the base implementation. You can do this by adding the following to your package.json:

{
	// your normal package.json
	// ...
	"op-sqlite": {
	  "sqlcipher": false,
	  "crsqlite": false,
	  "performanceMode": true,
	  "iosSqlite": false,
	  "sqliteFlags": "-DSQLITE_DQS=0",
	  "fts5": true,
	  "rtree": true,
	  "libsql": false,
	  "sqliteVec": true,
	  "tokenizers": ["simple_tokenizer"]
	}
}

All keys are optional, only turn on the features you want:

Some combination of features are not allowed. For example sqlcipher and iosSqlite since they are fundamentally different sources. In this cases you will get an error while doing a pod install or during the Android build.

🚨🚨🚨 IOS PODS USE_FRAMEWORKS BREAKS OP-SQLITE 🚨🚨🚨

In case you are using use_frameworks (for example because you are using react-native-firebase) this will break the compilation process and force the compilation to use the embedded sqlite on iOS. One possible workaround is putting this in your Podfile:

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.eql?('op-sqlite')
      def pod.build_type
        Pod::BuildType.static_library
      end
    end
  end
end

It forces static compilation on op-sqlite only. Since everything is compiled from sources this SHOULD work, however do it at your own risk since other compilation errors might arise. It is possible you will not get any error, but you will not be using the latest version of sqlite but rather the OS embedded one.