By Oscar Franco
Twitter • YouTube • [Email](mailto:[email protected]?subject=I%20need%20a%20Freelancer)
OP-SQLite also supports libsql as a “sqlite” implementation. You can just turn it on by modifying your package.json:
"op-sqlite": {
"libsql": true
}
Currently support is experimental and feedback is appreciated. You cannot use sqlcipher and libsql at the same time, only turn on one or the other.
Unlike regular sqlite, libsql does not support certain features but adds others. Otherwise the API is the same as regular use with sqlite.
Libsql allows you to connect to remote libsql databases:
import {openRemote} from '@op-engineering/op-sqlite';
const remoteDb = openRemote({
url: 'url',
authToken: 'token'
});
This is a purely remote database. You can however create a local database that syncs to a remote database:
import {openSync} from '@op-engineering/op-sqlite';
const remoteDb = openSync({
name: 'myDb.sqlite',
url: 'url',
authToken: 'token',
syncInterval: 1 // Optional, in seconds
});
You can force a sync to your remote database by calling the sync()
method. This is only available for libsql contexts:
remoteDb.sync();
However, by using libsql the following features are not available due to lack of support in the library itself: