Knex.js dialect for Expo SQLite
yarn add @expo/knex-expo-sqlite-dialect
--- a/babel.config.js
+++ b/babel.config.js
@@ -3,6 +3,7 @@ module.exports = function (api) {
return {
presets: [
'babel-preset-expo',
+ 'module:@expo/knex-expo-sqlite-dialect/babel-preset',
],
};
};
import ExpoSQLiteDialect from '@expo/knex-expo-sqlite-dialect';
import Knex from 'knex';
const knex = Knex({
client: ExpoSQLiteDialect,
connection: {
filename: 'MyDB.db',
},
});
packages/knex-expo-sqlite-dialect
The main package
Since Knex.js is developed on Node.js runtime, some of Node.js dependencies are not available on React Native. The Babel preset uses the babel-plugin-module-resolver
plugin to alias these Node.js modules to other supported modules.
apps/example
The example app replicated from the with-sqlite
example with Knex.js integration.